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
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUFF 5120

void strrev(char *str) {
	char ch;
	int i,j;

	i = strlen(str) - 1;
	j = 0;

	while (str[i] < '0') 
		str[i--] = '\0';

    	while (i > j) {
		ch = str[i];
		str[i] = str[j];
		str[j] = ch;
		i--;j++;
	}
}

int main() {
	char a[BUFF], b[BUFF], *pa, *pb, r;
	memset(a, 0, BUFF);
	memset(b, 0, BUFF);
	fgets(a, BUFF, stdin);
	fgets(b, BUFF, stdin);
	strrev(a);
	strrev(b);
	pa = a;
	pb = b;
	r = 0;
	while (*pa || *pb) {
		if (*pa) *pa -= '0';
		if (!*pb) *pb = '0';
		*pa += *pb + r;
		r = 0;
		if (*pa > '9') {
			r = 1;
			*pa -= 10;
		}
		pa++; pb++;	
	}
	if (r)
		*pa = '1';
	strrev(a);
	puts(a);
	return 0;
}