求1到10的阶乘之和的程序运行得不到我想要的结果,请各位帮忙看一下哪里出问题了,现在烦恼着
#include<stdio.h>int main()
{ int a,b,c=0;
for(a=1;a<=10;a++)
{
for(b=1;a>0;a--)
{ b*=a;
}
c=c+b;
}
printf("%d\n",c);
return 0;
}
#include<stdio.h> int main() { int a,b,c=0,d=1; for(a=1;a<=10;a++) { for(b=1;b<=a;b++) { d*=b; } c=c+d; d=1; } printf("%d\n",c); return 0; }
#include <stdio.h> unsigned foo( unsigned n ) { unsigned s = 0; for( ; n!=0; --n ) s = (s+1)*n; return s; } int main( void ) { printf( "%u\n", foo(10) ); }
#include<stdio.h> int main() { int a,b = 1,c = 0; for(a=1;a<=10;a++) { b *= a; c += b; } printf("%d\n",c); return 0; }