int main()
{
int i,n,sum;
printf(“Input n:”);
scanf(“%d”,&n);
sum=0;
i=1;
while(i<=n)
{
sum+=i;
i++;
}
printf(“sum=%d\n”,sum);
return 0;
}
计算并输出1+2+3+。。。+n的值
最新推荐文章于 2023-05-05 20:16:55 发布
int main()
{
int i,n,sum;
printf(“Input n:”);
scanf(“%d”,&n);
sum=0;
i=1;
while(i<=n)
{
sum+=i;
i++;
}
printf(“sum=%d\n”,sum);
return 0;
}
>