struct big 成员列表一览:
int ten[4]={1,10,100,1000};//构造万进制时用的系数
struct big{
bool tag;//符号
vector<int> d;//存储数值
int base;//进制
big();
big(const big&);//复制构造函数
big(const string&,const int&);//字符串构造函数,转换为相应的进制 。以POJ 1220 为标准
big(int,const int&);//把int转换为相应的进制
big(const string&);//默认的万进制
void change_base(const int&);//转换为相应的进制
void tail();//去0
void operator=(const big&);//赋值
void operator=(const string&);
void operator=(const int&);
void Dec();//数值加1
void Inc();//数值减1
big add(const big&)const; //数值相加
big minus(const big&)const;//数值上 大数减小数
big mul(const big&)const; //数值相乘,顺便处理符号
void operator+=(const int&);//与int型的 加和减 运算都转换为big大整数类再运算,因为符号难处理。。
void operator-=(const int&);
big operator+(const int&)const;
big operator-(const int&)const;
void operator*=(const int&);//与int的乘法也转换为big大整数类再运算,差不多
big operator*(const int&)const;
void operator+=(const big&);//基于 add() 和 minus() 的加,减运算
big operator+(const big&)const;
void operator-=(const big&);
big operator-(const big&)const;
big operator*(const big&)const;//朴素乘法
void operator*=(const big&);
//friend smaller(const big&,const big&,const int&);//除法用到 //outside of the struct
//friend Minus(big&,const big&,const int&); //除法用到 //outside of the struct
void dou(const big&);//本质为*this=parameter*2; //不用转换为big再乘,除法用到
big operator/(const int&)const;//除法 !!!限于万进制的big
big operator/(const big&)const;
big operator%(const big&)const;//取余 基于 除法,减法,乘法 ,懒---
big operator%(const int&)const;
friend istream&operator>>(istream&,big&);
friend ostream&operator<<(ostream&,const big&);//输出万进制的话需要#include<iomanip>
void operator++();//自增 有点多余
void operator--();//自减
int compare(const big&)const;//数值比较函数 左边大于右边 返回 -1 ,等于放回 0,小于返回 -1
bool operator<(const big&)const;//基于 compare() 的比较运算符重载
bool operator>(const big&)const;
bool operator==(const big&)const;
bool operator>=(const big&)const;
bool operator<=(const big&)const;
bool operator!=(const big&)const;
}mid[14];//除法用到,存储除数的(2次幂)倍数,做减法,模拟竖式
构造函数:
big::big(){tag=0;base=1e4;}
big::big(const big&a){
base=a.base;
d=a.d;
tag=a.tag;
}
big::big(const string&s,const int&b){
if(s[0]=='-')tag=1;else tag=0;
base=b;
int e;
if(tag) e=1;else e=0;
int len=s.size();
for(int i=len-1;i>=e;i--){
if(s[i]<='9') d.push_back(s[i]-48);
else if(s[i]<=90) d.push_back(s[i]-55);
else