神奇的高精度:
支持高精度加法,大于小于比较,赋值。
用了 *this
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 30
struct bigint
{
int a[maxn];
bigint()
{
memset(a,0,sizeof(a));
}
bigint& operator =(const string s)
{
int k=0;
for(int i=s.size()-1;i>=0;i--)
{
k++;
a[k]=s[i]-'0';
}
a[0]=s.size();
return *this;
}
bigint& operator =(const int a)
{
int num=a,i=0;
while(num!=0)
{
i++;
this->a[i]=num%10;
num/=10;
}
this->a[0]=i;
return *this;
}
bigint operator +(const bigint b)
{
bigint c;
c.a[0]=max(a[0],b.a[0]);
for(int i=1;i<=c.a[0];i++