参考别人的方法,没什么好说,看码基本都能懂
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX = 100001;
int main()
{ int a[MAX];
int n,i,j,k;
while(cin>>n){
a[0] = 1;
int num = 1;
for(i=1;i<=n;i++){
k = 0;
for(j=0;j<num;j++)
{
a[j] = a[j]*i +k;
k = a[j]/10;
a[j] = a[j]%10;
}
while(k)
{
a[num ++] = k%10;
k /= 10;
}
}
for(j=num-1;j>=0;j--)
cout<<a[j];
cout<<endl;
}
return 0;
}