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
37
38
39
40
41
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int reszta = 0, it = 0;
	string a, b, x = "";
	cin >> a >> b;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	if (a.size() < b.size()) swap(a, b);
	for (it; it < b.size(); it++) {
		string v1 = ""; v1 += a[it];
		string v2 = ""; v2 += b[it];
		int value1 = atoi(v1.c_str());
		int value2 = atoi(v2.c_str());
		int wartosc = value1 + value2 + reszta;
		x += to_string(wartosc % 10);
		reszta = wartosc / 10; 
	}

	while (it < a.size()) {
		string v = ""; v += a[it];
		int value = atoi(v.c_str());
		int wartosc = value + reszta;
		x += to_string(wartosc % 10);
		reszta = wartosc / 10;
		it++;
	}

	if (reszta > 0) x += to_string(reszta);

	for (int i = x.size() - 1; i >= 0; i--) cout << x[i];
	cout << '\n';

	return 0;
}