#include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> using namespace std; const int MAX = 110; //终于过了的.... // 要记得判断字符串长度!~ class CHugeInt { char p[250]; public: CHugeInt(char* s){ strcpy(p,s); } CHugeInt(int s){ sprintf(p,"%d",s); } friend ostream& operator<<(ostream & cout, CHugeInt a){ cout<<a.p; return cout; } CHugeInt operator+(CHugeInt & b){ CHugeInt a1(p); a1 += b.p; return a1; } friend CHugeInt operator+(int N, CHugeInt& a){ CHugeInt a1(a.p); a1 += N; return a1; } CHugeInt operator+(int N){ CHugeInt a1(p); a1 += N; return a1; } CHugeInt & operator++(){ (*this) += 1; return*this; } friend CHugeInt operator++(CHugeInt& b,int){ CHugeInt b1(b.p); b += 1; return b1; } CHugeInt & operator +=(int N){ char PB[250]; sprintf(PB,"%d",N); char pa[250]; char pb[250]; if(strlen(p)>=strlen(PB)){ strcpy(pa,p); strcpy(pb,PB); } else{ strcpy(pb,p); strcpy(pa,PB); } int alen=strlen(pa); int blen=strlen(pb); int A,B,j=0; char result[250]; int i,m,n; for( i=0,m=alen-1,n=blen-1;n>=0;i++,m--,n--){ A=pa[m]-'0'; B=pb[n]-'0'; if(A+B+j>9){ result[i]=A+B-10+j+'0'; j=1; } else{ result[i]=A+B+j+'0'; j=0; } } int r; for(r=i;m>=0;r++,m--){ A=pa[m]-'0'; if(A+j>9){ result[r]=A+j-10+'0'; j=1; } else{ result[r]=A+j+'0'; j=0; } } if(j==1){ result[r]='1'; r++; } result[r]='