面向对象
#include <bits/stdc++.h>
using namespace std;
class BigInt {
private:
string num;
public:
#define proces() do { \
if (t > '9') { \
t -= 10; \
flag = true; \
} else { \
flag = false; \
} \
c += t; \
i++; \
} while (0)
BigInt(string s, bool bRevs = true) {
num = move(s);
if (bRevs) reverse(num.begin(), num.end());
}
BigInt operator + (BigInt &b) {
string c;
int i = 0;
bool flag = false;
char t;
while (i < num.size() && i < b.num.size()) {
char t = num[i] + b.num[i] - '0' + (flag ? 1 : 0);
proces();
}
while (i < num.size()) {
char t = num[i] + (flag ? 1 : 0);
proces();
}
while (i < b.num.size()) {
char t = b.num[i] + (flag ? 1 : 0);
proces();
}
if (flag) c += '1';
return BigInt(c, false);
}
friend ostream &operator << (ostream &out, const BigInt &n);
};
ostream &operator << (ostream &out, const BigInt &a) {
for (int i = a.num.size() - 1; ~i; --i) {
out << a.num[i];
}
return out;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
string s1, s2;
while (cin >> s1 >> s2) {
BigInt n1(s1), n2(s2);
cout << (n1 + n2) << endl;
}
return 0;
}


京公网安备 11010502036488号