比a+b难一点
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct Bign
{
int f[1005];
int len;
void read()
{
string s;
cin>>s;
len=s.length();
for(int i=1;i<=len;i++)
{
f[i]=s[len-i]-'0';
}
}
void print()
{
bool yes=false;
for(int i=len;i>=1;i--)
{
if(f[i]!=0)
{
yes=true;
}
if(yes)
{
cout<<f[i];
}
}
cout<<endl;
}
};
Bign operator - (Bign a,Bign b)
{
Bign c;
c.len=a.len;
int t=0;
for(int i=1;i<=c.len;i++)
{
c.f[i]=a.f[i]-t;
if(i<=b.len)c.f[i]-=b.f[i];
if(c.f[i]<0)
{
c.f[i]+=10;
t=1;
}
else
{
t=0;
}
}
while(c.f[c.len]==0&&c.len>1)
{
c.len--;
}
return c;
}
bool operator < (Bign a,Bign b)
{
if(a.len!=b.len)
{
return a.len<b.len;
}
else
{
return a.f[a.len]<b.f[b.len];
}
}
int main() {
Bign a,b;
a.read();b.read();
Bign c;
if(a<b)c=b - a;
else c=a - b;
c.print();
return 0;
}