#include <iostream>
using namespace std;
const int N = 40000;
void JieCheng(int n)
{
int result[N]; //保存结算结果的数组
int height; //结果的最高位长度
result[0] = 1;
height = 1;
//计算
for(int i=1;i<=n;i++)
{
int res = 0; //进位
for(int j=0;j<height;j++)
{
int buf = result[j]*i + res; //计算结果 ——只要将这里的'i'修改为'n',就可以用来计算n^n
result[j] = buf%10; //取当前位
res = buf/10; //进位
}
while(res)
{
result[height++] = res%10; //取当前位
res /= 10; //进位
}
}
//输出
for(int i=height-1;i>=0;i--)
cout<<result[i];
cout<<endl<<" 总长度是:"<<height<<endl;
}
int main()
{
int n;
cout<<"Input a number:";
cin>>n;
if(n>10000 || n<0)
cout<<"输入了不合法的数字!";
else
JieCheng(n);
return 0;
}