99问答网
所有问题
C语言的问题,不知道怎么书写 题目编写一个程序,求s=1+(1+2)+(1+2+3)+...+(1+2+3+...+n)。
如题所述
举报该问题
推荐答案 2017-08-21
#include<stdio.h>
int main()
{int i,n,t=0,s=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{ t+=i;
s+=t;
}
printf("%d\n",s);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://44.wendadaohang.com/zd/YV63KGDGKGZGDYWKDYW.html
相似回答
大家正在搜