//C语言基础例程001 求前n项和
#include<stdio.h>
int signa(int n)
{
int i = 0,sum = 0;
while(i <= n)
{
//i++;放在这边每次运算多加一个数,如输入3,sum = 1+2+3+4 =10;
sum = sum + i;
i++;//放在这边求1到n的和,即如输入3,sum = 1+2+3=6;先参加运算后自增
}
return sum;
}
int main()
{
int m,total;
scanf("%d",&m);
total= signa(m);
printf("total= %d\n",total);
return0;
}