大数阶乘
来源:互联网 发布:成吉思汗舞曲格格 知乎 编辑:程序博客网 时间:2024/05/21 20:26
#include<iostream>
using namespace std;
int main()
{
int c,n,j;
int a[2000];
int d=1;
int l;
int temp,i;
while(cin>>n)
{ memset(a,0,sizeof(a));
a[0]=1;
for(i=2;i<=n;i++)
{
for(c=0,j=1;j<=d;++j)
{
temp=a[j-1]*i+c;
a[j-1]=temp%10;
c=temp/10;
}
while(c)
{
a[++d-1]=c%10;
c/=10;
}
}
l=d-1;
while(a[l]==0)
{
l--;
}
for(int k=l;k>=1;--k)
{
cout<<a[k-1];
}
cout<<endl;
}
system("pause");
return 0;
}
using namespace std;
int main()
{
int c,n,j;
int a[2000];
int d=1;
int l;
int temp,i;
while(cin>>n)
{ memset(a,0,sizeof(a));
a[0]=1;
for(i=2;i<=n;i++)
{
for(c=0,j=1;j<=d;++j)
{
temp=a[j-1]*i+c;
a[j-1]=temp%10;
c=temp/10;
}
while(c)
{
a[++d-1]=c%10;
c/=10;
}
}
l=d-1;
while(a[l]==0)
{
l--;
}
for(int k=l;k>=1;--k)
{
cout<<a[k-1];
}
cout<<endl;
}
system("pause");
return 0;
}
- 大数阶乘
- 大数阶乘。
- 大数阶乘
- ~阶乘~大数
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘!!
- 大数阶乘
- 大数阶乘
- 大数阶乘
- android shape的使用
- 浅拷贝.深拷贝
- 《Widgets Module》学习笔记
- ORACLE游标
- windbg 相关命令
- 大数阶乘
- windows系统默认调试器设置
- 错误:Warning: File `../table/table.pro' has modification time 3.9e+08 s in the future
- 用HTML5实现手机摇一摇的功能
- UESTC Training for Data Structures——B
- VMWare8无法最小化的问题
- VC++ HotKey
- 全局匹配模式
- 数据库中的约束