大数A+B问题

A + B Problem II
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u


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*/
#include
#include
int main()
{
    int t,num=1,flag=0;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        char a[1000],b[1000];
        int x[1000]={0},y[1000]={0},sum[1001]={0};
        int i,j;
        if (flag)
            printf("\n");
        flag=1;
        scanf("%s %s",a,b);
        int lena,lenb;
        lena=strlen(a);
        lenb=strlen(b);
        for (i=lena-1,j=0;i>=0;i--,j++)
        {
            x[j]=a[i]-48;
        }
        for (i=lenb-1,j=0;i>=0;i--,j++)
        {
            y[j]=b[i]-48;
        }
        if (lena





你可能感兴趣的:(大数问题,算法)