-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA+B_problem.c
73 lines (62 loc) · 1.37 KB
/
A+B_problem.c
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// #include<stdio.h>
// #include<string.h>
// #define M 1000
// int p = 0;
// void reverse(char *str);
// void add(char *sum, char a, char b, int n);
// int main()
// {
// char A[M], B[M], sum[M + 1];
// memset(A, 0, M);
// memset(B, 0, M);
// scanf("%s", A);
// getchar();
// scanf("%s", B);
// reverse(A);
// reverse(B);
// int i = 0, j = 0, lenA = strlen(A), lenB = strlen(B);
// while(i < lenA && j < lenB && A[i] && B[j]){
// add(sum, A[i], B[j], i);
// i++;
// j++;
// }
// while(i < lenA && A[i]){
// add(sum, A[i], '0', i);
// i++;
// }
// while(j < lenB && B[j]){
// add(sum, '0', B[j], i);
// j++;
// }
// reverse(sum);
// printf("%s", sum);
// return 0;
// }
// void reverse(char *str){
// int len = strlen(str);
// int i;
// for(i = 0; i < len / 2; i++){
// char temp = str[i];
// str[i] = str[len - 1 - i];
// str[len - 1 - i] = temp;
// }
// }
// void add(char *sum, char a, char b, int n){
// int temp = a - '0' + b - '0' + p;
// if(temp >= 10){
// temp -= 10;
// p = 1;
// }else{
// p = 0;
// }
// sum[n] = temp + '0';
// }
#include<stdio.h>
int main()
{
int A, B;
while(scanf("%d %d", &A, &B) != EOF){
printf("%d\n", A + B);
}
return 0;
}