【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
【AC代码】
1 #include<stdio.h> 2 #include<string.h> 3 #define max(a, b) a > b ? a:b 4 5 char a[1024]; 6 char b[1024]; 7 char c[1024]; 8 int i; 9 10 void reverse(char *a) 11 { 12 int aa = strlen(a); 13 char t; 14 for(i=0; i<aa/2; i++) 15 { 16 t = a[i]; 17 a[i] = a[aa-1-i]; 18 a[aa-1-i] = t; 19 } 20 } 21 void add(char *a, char *b, char *c) 22 { 23 int cc = 0, aa = strlen(a), bb = strlen(b); 24 int len = max(aa, bb); 25 for(i=0; i<aa; i++) 26 { 27 a[i] = a[i]-'0'; 28 } 29 for(i=0; i<bb; i++) 30 { 31 b[i] = b[i]-'0'; 32 } 33 for(i=0; i<len; i++) 34 { 35 c[i] = (a[i]+b[i]+cc) % 10 + '0'; 36 cc = (a[i]+b[i]+cc) / 10; 37 } 38 if(cc) c[i++] = cc + '0'; 39 c[i] = '