C语言编程问题:求 1!+2!+3!+...+n!
C语言编程问题:求 1!+2!+3!+...+n!
日期:2020-11-21 11:07:45 人气:1
把sum=sum+x;移到}后、x=1;前。
int main(void){
int sum,n,x,t;
scanf("%d",&n);
for(sum=0,x=t=1;t<=n;sum+=x*=t++);
printf("%d\n",sum);
return 0;
}
扩展资料:
C的数据类型包括:整型(short,int,long,long long)、字符型(char)、实型或浮点型(单精度float和双精度double)、枚举类型(enum