In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
输入格式
The input will consist of a series of integers n, one integer per line.
输出
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.
样例输入
1
100
样例输出
1
5050
void main() {int a,b,c; c=scanf("%d %d",&a,&b); printf("%d",c); }为什么我输入a 1 , c的值就为0,输入1 a,c的值为1
scanf返回接收到的变量值的个数。 int a,b,c。 a 1进去时,试图用字符‘a’对a赋值,肯定是错的,于是退出,返回成功接收到赋值的个数 0. 1 a进去时,首先a能获取1.但b不能获取'a',于是返回只是1 如果是 1 1的话,那就都成功,返回2