请高手帮帮我编写这个求和的程序,用C语言Problem DescriptionHey,welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem,your task is to calculate SUM(n) = 1 + 2 + 3 + ...+ n.InputThe input will consist of a series of i
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 11:57:15
请高手帮帮我编写这个求和的程序,用C语言Problem DescriptionHey,welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem,your task is to calculate SUM(n) = 1 + 2 + 3 + ...+ n.InputThe input will consist of a series of i
请高手帮帮我编写这个求和的程序,用C语言
Problem Description
Hey,welcome to HDOJ(Hangzhou Dianzi University Online Judge).
In this problem,your task is to calculate SUM(n) = 1 + 2 + 3 + ...+ n.
Input
The input will consist of a series of integers n,one integer per line.
Output
For each case,output SUM(n) in one line,followed by a blank line.You may assume the result will be in the range of 32-bit signed integer.
Sample Input
1
100
Sample Output
1
5050
/*请注意几点,第一,可以一直输入并且每个输入占一行.第二,当输入完毕之后才将结果一起输出,且每个输出结果占一行,并且后边跟着一个空行.*\
使用EOF的方法,是ctl+z结束
请高手帮帮我编写这个求和的程序,用C语言Problem DescriptionHey,welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem,your task is to calculate SUM(n) = 1 + 2 + 3 + ...+ n.InputThe input will consist of a series of i
#include
int main()
{
int n,i;
while(scanf("%d",&n)!=EOF) /使用EOF/
{
long sum=0;
for(i=1;i