http://acm.hdu.edu.cn/showproblem.php?pid=1002
#include<iostream>
#include<string.h>
#define max(a,b) a>b?a:b
using namespace std;
int main()
{
int s[1002];
char a[1001],b[1001];
int t,i,j;
cin>>t;
int Case=1;
while(t--)
{
cin>>a>>b;
int x=strlen(a),y=strlen(b);
int MAX=max(x,y);
memset(s,0,sizeof(s));
j=0;
for(i=x-1;i>=0;i--)
s[j++]+=a[i]-'0';
for(i=y-1,j=0;i>=0;i--,j++)
{
s[j]+=b[i]-'0';
}
for(i=0;i<MAX;i++)
{
if(s[i]>=10)
{
s[i]=s[i]%10;
s[i+1]+=1;
}
}
i=MAX;
cout<<"Case "<<Case++<<':'<<endl;
printf("%s + %s = ",a,b);
while(s[i]==0)i--;
if(i<0)
cout<<0<<endl;
else
{
for(;i>=0;i--)
cout<<s[i];
cout<<endl;
}
if(t)cout<<endl;
}
return 0;
}