标签:else size name amp pac char bsp this color
1 /* 2 高精度进制加法 3 n为进制(n<=36) 4 */ 5 #include<bits/stdc++.h> 6 using namespace std; 7 const int maxn=10000; 8 int n; 9 struct bign{ 10 int d[maxn],len; 11 inline bign(){len=1;memset(d,0,sizeof(d));} 12 inline bign operator = (const char* num) 13 { 14 memset(d,0,sizeof(d)); 15 len=strlen(num); 16 for(int i=0;i<len;i++) 17 { 18 if(num[len-1-i]>‘9‘) d[i]=10+num[len-i-1]-‘A‘; 19 else d[i]=num[len-i-1]-48; 20 } 21 return *this; 22 } 23 inline bign operator + (const bign &b) 24 { 25 bign c; 26 int x=0,i,lenmax=max(len,b.len); 27 for(i=0;i<lenmax;i++) 28 { 29 c.d[i]=d[i]+b.d[i]+x; 30 x=c.d[i]/n; 31 c.d[i]%=n; 32 } 33 x?c.d[i]=i:i--; 34 c.len=i+1; 35 return c; 36 } 37 inline string str () const 38 { 39 char s[maxn]={}; 40 for(int i=0;i<len;i++) 41 { 42 if(d[len-i-1]>9) s[i]=‘A‘+d[len-i-1]-10; 43 else s[i]=d[len-i-1]+48; 44 } 45 return s; 46 } 47 }a,b; 48 inline istream& operator >> (istream &in,bign &x) 49 { 50 char s[maxn]={}; 51 in>>s; 52 x=s; 53 return in; 54 } 55 inline ostream& operator << (ostream &out,const bign &x) 56 { 57 out<<x.str(); 58 return out; 59 } 60 int main() 61 { 62 cin>>n>>a>>b; 63 cout<<a+b; 64 return 0; 65 }
标签:else size name amp pac char bsp this color
原文地址:https://www.cnblogs.com/yu-xing/p/10125469.html