计算200的阶乘
来源:互联网 发布:基调网络监测联盟 编辑:程序博客网 时间:2024/04/29 00:16
#include<iostream>
#include<string>
using namespace std;
const int Max=1000;
class BigNum
{
public:
BigNum(int a)
{
int i,j=0;
for(i=0;i<Max;i++)
theNum[i]=0;
while(a){
theNum[j]=a%10;
a=a/10;
j++;
}
}
BigNum operator * (const BigNum &x){
BigNum result(0);
for(int i=0;i<Max;i++)
{
BigNum temp(0);
if(!x.theNum[i]) continue;
for(int j=0;j<x.theNum[i];j++)
temp=temp+*this;
result=result+(temp<<i);
}
return result;
}
BigNum operator<<(int x){
for(int i=Max-1;i>Max-1-x;i--)
if(theNum[i]){
cerr<<"error!"<<endl;
system("pause");
exit(1);
}
for(int j=Max-1;j>=x;j--)
theNum[j]=theNum[j-x];
for(int k=x-1;k>=0;k--)
theNum[k]=0;
return *this;
}
BigNum operator+(const BigNum & x)const{
BigNum temp(0);
int fore=0;
for(int i=0;i<Max;i++)
{
int j=theNum[i]+x.theNum[i]+fore;
temp.theNum[i]=j%10;
fore=j/10;
}
return temp;
}
friend ostream& operator<<(ostream & out,const BigNum x){
int i=Max-1;
while(!x.theNum[i])i--;
for(int j=i;j>=0;j--)
out<<(int)x.theNum[j];
return out;
}
private:
char theNum[Max];
};
BigNum The_Result(int n)
{
if(n==0) return 1;
else return BigNum(n)*The_Result(n-1);
}
int main()
{
int n;
cin>>n;
cout<<The_Result(n)<<endl;
return 0;
}
- 计算200的阶乘
- 计算N的阶乘
- 计算N的阶乘
- 计算1000的阶乘
- 阶乘位数的计算
- 计算10000的阶乘
- 计算100的阶乘
- 计算n的阶乘
- 小数点的阶乘计算
- 计算大数的阶乘
- 计算阶乘的函数
- 计算n的阶乘
- 计算n的阶乘
- 1977的阶乘计算
- 阶乘的计算
- 计算n的阶乘
- 计算10000的阶乘
- 计算n的阶乘
- 通用的ASP全能分页类
- 字符、字符数组、char、string的区别分析
- 健身同时顺便做做保养
- 鼠标右击添加命令行
- PetShop的系统架构设计
- 计算200的阶乘
- 按摩10法:养颜补脑强身体
- ASP.NET定义主题和外观
- 写程序呀写程序 你们也是这样学写程序的么 (9)
- 健身提醒 最常见的三个瑜伽误区
- 地图填色问题
- 用ASP.NET实现在线用户统计
- [C语言]Scanf()函数详细介绍篇
- SQL Server 2005全文检索技术在网站上的应用实录