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
42
43
44
#include <bits/stdc++.h>
using namespace std;

int p = 0, w, dlugosc1, dlugosc2, minndl;
string s1, s2, s3 = "";

int main( )
{
  cin >> s1 >> s2;

  dlugosc1 = s1.length();
  dlugosc2 = s2.length();
  minndl = min(dlugosc1, dlugosc2);

  for(int i = 0; i < minndl; i++ )
  {
      dlugosc1--;
      dlugosc2--;
      w  = (int(s1[dlugosc1])) + (int(s2[dlugosc2])) + p - 96;
      p  = w / 10;
      s3 = (char((w % 10) + 48)) + s3;

  }

  while(dlugosc1 > 0)
  {
      dlugosc1--;
      w  = s1[dlugosc1] + p - 48;
      p  = w / 10;
      s3 = (char((w % 10) + 48)) + s3;
  }

  while(dlugosc2 > 0)
  {
      dlugosc2--;
      w  = s2[dlugosc2] + p - 48;
      p  = w / 10;
      s3 = (char((w % 10) + 48)) + s3;
  }

  if(p > 0) s3 = (char(p + 48)) + s3;
  if(s3 == "") s3 = "0";
  cout << s3 << endl;
}