1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <string>
using namespace std;

int main() {
	string a = "";
	string b = "";
	cin >> a;
	cin >> b;
	int aIt = a.length() - 1;
	int bIt = b.length() - 1;
	int temp = 0;
	int last = 0;
	string result = "";
	while (aIt >= 0 || bIt >= 0) {
		int aNum = 0;
		int bNum = 0;
		if (aIt >= 0) {
			aNum = (int)a[aIt] - 48;
		}
		if (bIt >= 0) {
			bNum = (int)b[bIt] - 48;
		}
		temp = aNum + bNum + last;
		int number = temp % 10;
		last = temp / 10;
		result = to_string(number) + result;
		aIt--;
		bIt--;
	}
	if (last > 0) {
		result = to_string(last) + result;
	}
	cout << result;

}