标签:
1 #include<iostream> 2 #include<string.h> 3 using namespace std; 4 5 int main(){ 6 int n,A[100000]; 7 cin>>n; 8 memset(A,0,sizeof(A)); 9 A[0] = 1; 10 int bit = 0; 11 for(int i = 1;i <= n;i++){ 12 int tem = 0; 13 for(int j = 0;j <= bit;j++){ 14 A[j] = A[j] * i + tem; 15 if(j==bit){ 16 if(A[j] >= 10) 17 bit++; 18 } 19 if(A[j] >= 10){ 20 tem = A[j] / 10; 21 A[j] = A[j] % 10; 22 } 23 else 24 tem = 0;//易错 25 26 } 27 } 28 for(int i = bit;i >= 0;i--){ 29 cout<<A[i]; 30 } 31 cout<<endl; 32 return 0; 33 }
要注意进位只为后一位产生的,要记得更新,不管是否大于9
标签:
原文地址:http://www.cnblogs.com/chenzhiyuan/p/5171373.html