高精度阶乘
#include<iostream> #include<string.h> using namespace std; int main(){ int n,A[100000]; cin>>n; memset(A,0,sizeof(A)); A[0] = 1; int bit = 0; for(int i = 1;i <= n;i++){ int tem = 0; for(int j = 0;j <= bit;j++){ A[j] = A[j] * i + tem; if(j==bit){ if(A[j] >= 10) bit++; } if(A[j] >= 10){ tem = A[j] / 10; A[j] = A[j] % 10; } else tem = 0;//易错 } } for(int i = bit;i >= 0;i--){ cout<<A[i]; } cout<<endl; return 0; }