您的位置:首页 > 其它

杭电oj 1001 记录一下

2014-12-19 21:51 274 查看
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">今天因为自己不知道在做什么,然后拖到晚上才做的</span>

 1001题目

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

 

Author

DOOM III

刚开始,英文不好,然后刚开始以为是输入两个数,先输入第一个起始数字,结果提交发现错误啊,我也是醉了,后来搞百度了一下,发现原来这里不是输入两个数,一个数就好了,刚开始应该是没有难度的题,坚持才是胜利

我的代码是这样的

#include<stdio.h>

int main()
{
int a,b,sum = 0,i=1;
while(scanf("%d",&b)!=EOF)
{
for(i =1;i<=b;i++)
sum+=i;
printf("%d\n\n",sum);
sum=0;
}
return 0;
}

    继续坚持,坚持才是胜利。加油
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: