描述
Your task is to find the sum of all integer numbers lying between 1 and N inclusive.
-
输入
-
There are multiple test cases.
The input consists of a single integer N that is not greater than 10000 by it's absolute value. 输出
- Write a single integer number that is the sum of all integer numbers lying between 1 and N inclusive. 样例输入
-
3
样例输出
-
6
#include<cstdio>
using namespace std;
int main(){int a,ans;while(scanf("%d",&a)!=EOF){if(a>0)ans = (1+a)*a/2;else{ans = 0;for(int i=a ;i<=1 ;i++){ans += i;} }printf("%d\n",ans);}return 0;
}