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
1 #include <stdio.h> 2 #include <string.h> 3 #define N 1001 4 5 int main(){ 6 int T; 7 char A[N]; 8 char B[N]; 9 int sum[N]; 10 char temp[N]; 11 int A_length; 12 int B_length; 13 int i; 14 int length; //长度差 15 int first; 16 int second; 17 int flag; 18 int flag2; 19 int time; 20 21 scanf("%d",&T); 22 time=1; //time表示第几个输入数据组 23 24 while(T--){ 25 flag=0; 26 flag2=0; 27 scanf("%s%s",A,B); 28 29 printf("Case %d: ",time); 30 time++; 31 printf("%s + %s = ",A,B); 32 33 A_length=strlen(A); 34 B_length=strlen(B); 35 36 if(A_length<B_length){ //保证A的长度大于或者等于B的长度 37 strcpy(temp,A); 38 strcpy(A,B); 39 strcpy(B,temp); 40 } 41 42 A_length=strlen(A); 43 B_length=strlen(B); 44 length=A_length-B_length; 45 for(i=B_length-1;i>=0;i--){ //数组B往后移动 46 B[i+length]=B[i]; 47 } 48 49 for(i=0;i<length;i++) //数组B前面添加'0' 50 B[i]='0'; 51 52 B[A_length]='