1
1
2222222222
8888888888
0
0

2
11111111110

### 提示

#include <iostream>

#include <cstring>

#define MAX 100001

using namespace std;

class number

{

public:

friend istream &operator>>(istream &in,number &n)

{

in>>n.num;

return in;

}

friend ostream &operator<<(ostream &out,number &n)

{

return out;

}

friend bool flag_stop(number a,number b);

number operator +(number n);

private:

char num[MAX];

};

bool flag_stop(number a,number b)

{

if(a.num[0]==’0’&&b.num[0]==’0′)return true;

else return false;

}

/*************begin**************/

此处补全缺失代码

/***********end*********/

int main()

{

number a,b;

while(cin>>a>>b)

{

if(flag_stop(a,b))break;

number c=a+b;

cout<<c<<endl;

}

return 0;

}

### 代码如下

``````
#include <iostream>
#include <cstring>
#define MAX 100001
using namespace std;
class number
{
public:
friend istream &operator>>(istream &in,number &n)
{
in>>n.num;
return in;
}
friend ostream &operator<<(ostream &out,number &n)
{
return out;
}
friend bool flag_stop(number a,number b);
number operator +(number n);
private:
char num[MAX];
};
bool flag_stop(number a,number b)
{
if(a.num[0]=='0'&&b.num[0]=='0')return true;
else return false;
}
void reverse(char n[])
{
int len=strlen(n);
for(int i=len-1;2*i>len-1;i--)
{
swap(n[i],n[len-1-i]);
}
}
{
reverse(n1);
reverse(n2);
int i;
int len1=strlen(n1);
int len2=strlen(n2);
int min=len1<=len2?len1:len2;
int max=len1>len2?len1:len2;
for(i=0;i<min;i++)
{
result[i]=n1[i]+n2[i]-'0';
}
for(i=min;i<max;i++)
{
result[i]=len1>len2?n1[i]:n2[i];
}
for(i=0;i<max-1;i++)
{
result[i]-='0';
if(result[i]>9)
{
result[i+1]+=result[i]/10;
result[i]%=10;
}
result[i]+='0';
}
int k=max-1;
int last=result[max-1]-'0';
while(last)
{
result[k++]=last%10+'0';
last/=10;
}
result[k]=0;
reverse(result);
cout<<result;
}
number number::operator+(number n)
{
number s;
return s;
}
int main()
{
number a,b;
while(cin>>a>>b)
{
if(flag_stop(a,b))break;
number c=a+b;
cout<<c<<endl;
}
return 0;
}
``````