A+B Problem II

# A+B Problem II

## A+B Problem II

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

A,B must be positive.

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.

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.

[cpp]
#include
#include
using namespace std;
int main()
{
string s1,s2;int a[1005];
int i,j,k,t,d,x=1;cin>>d;
while(d–)
{
cin>>s1>>s2;
i=s1.size()-1;j=s2.size()-1;t=k=0;
while(i>=0&&j>=0)
{
a[k]=(s1[i]+s2[j]+t-96)%10;
if(s1[i]+s2[j]+t-96>=10) t=1;
else t=0;
k++;i–;j–;
}
if(i>=0)
{
while(i>=0)
{
a[k]=(s1[i]+t-48)%10;
if(s1[i]+t-48>=10) t=1;
else t=0;
k++;i–;
}
}
if(j>=0)
{
while(j>=0)
{
a[k]=(s2[j]+t-48)%10;
if(s2[j]+t-48>=10) t=1;
else t=0;
k++;j–;
}
}
if(t) a[k++]=t;//处理最高位
cout<<"Case "<