标签:printf int cst nbsp ams show ram scanf scan
求10000以内n的阶乘。
100
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
代碼實現:
1 #include<cstdio> 2 int n,a,fz[50000],ans[50000]={1,1}; 3 int main(){ 4 scanf("%d",&n); 5 for(int i=1;i<=n;i++) 6 for(int j=1;j<=ans[0];j++){ 7 ans[j]=ans[j]*i+fz[j];fz[j]=0; 8 if(ans[j]>9){ 9 fz[j+1]+=ans[j]/10; 10 ans[j]%=10; 11 if(j==ans[0]) ++ans[0]; 12 } 13 } 14 for(int i=ans[0];i>0;i--) printf("%d",ans[i]); 15 printf("\n"); 16 return 0; 17 }
。。。
标签:printf int cst nbsp ams show ram scanf scan
原文地址:http://www.cnblogs.com/J-william/p/6155807.html