本文共 634 字,大约阅读时间需要 2 分钟。
#includeint main(){ int n; scanf("%d",&n); if(n<=2) printf("%d\n",n); else{ int ans[10000],digit = 1;//位数 ans[0]=1; for(int i=2;i<=n;++i){ int c = 0;//进位 for (int j=1; j<=digit; ++j) { c = ans[j-1] * i + c; ans[j-1] = c %10; c = c/10; } while(c) { ++digit; ans[digit-1] = c%10; c = c/10; } } for (int i=digit; i>0; --i) { printf("%d",ans[i-1]); printf(i==1?"\n":""); } } return 0;}
转载地址:http://amhji.baihongyu.com/