...题目:
zhe
这就是题目的大体意思;
其实这个题目不是很难,我的思路是将字符串 a,b先逆序,然后再各个位数相加,记住一定不要忘记进位,尤其是最后那一位,得判断一下是否得进位;
下面是AC的代码
#include <algorithm>
class BigInt
{
private:
string str;
public:
BigInt(){}
BigInt(string s)
{
str = s;
}
friend istream& operator>>(istream& is,BigInt &b);
friend ostream& operator<<(ostream& os,const BigInt &b);
friend BigInt operator + (const BigInt &b1,const BigInt &b2);
};
istream& operator>>(istream& is,BigInt &b)
{
is >> b.str;
return is;
}
ostream& operator<<(ostream& os,const BigInt &b)
{
os << b.str;
return os;
}
BigInt operator + (const BigInt &b1,const BigInt &b2)
{
BigInt B;
string s1 = b1.str;
string s2 = b2.str;
reverse(s1.begin(),s1.en