#include <bits/stdc++.h>
using namespace std;
class largeIntegers {
private:
/* data */
int num[100] = {0};
int digits;
bool isPositive;
public:
friend istream &operator>>(istream &, largeIntegers &);
friend largeIntegers operator+(const largeIntegers &lhs, const largeIntegers &rhs);
void getLargeInteger(void);
void setLargeInteger(string);
void print(void);
largeIntegers();
largeIntegers(string);
};
int main() {
largeIntegers num1;
cin >> num1;
largeIntegers num2;
num2 = num1;
cin >> num1;
largeIntegers num3;
num3 = num1 + num2;
num3.print();
return 0;
}
largeIntegers operator+(const largeIntegers &lhs, const largeIntegers &integer)
{
largeIntegers temp;
int remainder = 0;
int digi = max(lhs.digits, integer.digits);
temp.digits = digi;
for (int i = 0; i < digi; i++) {
temp.num[i] = (remainder + lhs.num[i] + integer.num[i]) % 10;
remainder = (remainder + lhs.num[i] + integer.num[i]) / 10;
}
if (remainder) {
temp.num[digi] = remainder;
temp.digits++;
}
return temp;
}
largeIntegers::largeIntegers(string n) { setLargeInteger(n); }
largeIntegers::largeIntegers() {
isPositive = true;
digits = 0;
}
void largeIntegers::setLargeInteger(string n) {
int start = 0;
if (n[0] == '-') {
isPositive = false;
start = 1;
}
digits = 0;
for (int i = n.length() - 1; i >= start; i--) {
num[digits] = int(n[i]) - int('0');
digits++;
}
}
void largeIntegers::getLargeInteger(void) {
cout << "Enter a large integer:\n";
string n;
cin >> n;
setLargeInteger(n);
}
istream &operator>>(istream &isObject, largeIntegers &largeInt) {
string num;
isObject >> num;
largeInt.setLargeInteger(num);
return isObject;
}
void largeIntegers::print(void) {
if (!isPositive)
cout << "-";
for (int i = digits - 1; i >= 0; i--) {
cout << num[i];
}
cout << endl;
}