大数加法

Problem Description

I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.

Input

The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.

Output

For each test case, you should output two lines. The first line is “Case #:”, # means the number of the test case. The second line is the an equation “A + B = Sum”, Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.

Sample Input

2
1 2
112233445566778899 998877665544332211

Sample Output

Case 1:
1 + 2 = 3

Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110


mycode

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

#include<string.h>

int () {
int i,j,k=0;
char a[1001],b[1001];
int c[1001]={0};
scanf("%s%s",&a,&b);

int lena=strlen(a);
int lenb=strlen(b);
int l=lena>lenb?lena+1:lenb+1;

while(lena>0 && lenb>0) {
if(c[k]+a[lena-1]-'0'+b[lenb-1]-'0'>9) {
c[k]=c[k]+a[lena-1]-'0'+b[lenb-1]-'0'-10;
c[k+1]++;
k++;
lena--;
lenb--;
} else {
c[k]=a[lena-1]-'0'+b[lenb-1]-'0';
k++;
lena--;
lenb--;
}
}

if(lena>0) {
c[k]=c[k]+a[lena-1]-'0';
lena--;
k++;
while(lena>0){
c[k++]=a[lena--]-'0';
}
} else if(lenb>0) {
c[k]=c[k]+b[lenb-1]-'0';
lenb--;
k++;
while(lenb>0){
c[k++]=b[lenb--]-'0';
}
}
if(c[k]!=0) {
k++;
}

printf(" %s + %s = ",a,b);

for(i=k-1; i>=0; i--)
printf("%d",c[i]);
printf("n");

return 0;
}