zombie丶zzZ

## 杭电ACM Q1001

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`
``````import java.util.*;
public class Q1001{

public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int b=0,sum=0;
while(cin.hasNextInt())
{
b = cin.nextInt();
for(int i=b;i>=0;i--)
{
sum=sum+i;
}
System.out.println(sum);
}
}
}``````

运用累加，注意输出格式

### zombie丶zzZ

2013/08/12
0
0

sdulmy
2013/03/29
0
0

redraiment
2013/03/20
2.4K
42

2013/01/06
153
0

IO操作需要支持不同类型的设备和不同类型数据的接口。所以IO标准库使用了继承来定义一组面向对象的类。 1. 首先IO类型在三个头文件中定义 iostream定义控制窗口读写的类型，fstream定义读写已...

iaccepted
2011/11/28
0
0

Jenkins系列_插件安装及报错处理

shzwork

2
0
mysql mysql的所有查询语句和聚合函数（整理一下，忘记了可以随时看看）

edison_kwok

9
0

3
0

2
0

mbzhong

4
0