杭电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;
}
继续坚持,坚持才是胜利。加油
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;
}
继续坚持,坚持才是胜利。加油
相关文章推荐
- 杭电OJ 1000 1+1 记录一下
- Java解题-杭电OJ-1001题
- 杭电OJ-1001
- 杭电oj 1001
- 杭电OJ编码1001
- 杭电OJ 1001
- 杭电OJ-1001-(Sum Problem大整数求和问题)
- 杭电oj~~1001
- 杭电OJ 1001
- 杭电OJ--1001
- 我的杭电oj之旅——1001
- 杭电 oj 1002 A + B Problem II 记录
- 杭电OJ_DIY_YTW2_1001 A Mathematical Curiosity
- 杭电oj 1001
- 杭电oj1001排序 交换次数
- 杭电OJ 1001
- 杭电oj 1001 sum problem
- 杭电OJ1001
- 杭电OJ——第1000,1001题
- 杭电oj-1001-Sum Problem