题目:http://acm.hdu.edu.cn/showproblem.php?pid=1002
简单的大数问题
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char a[1001],b[1001];
int n,s1,s2,a1[1001],b1[1001],i,j,n1=0,t;
cin>>n;
t=n;
while(n--)
{
n1++;
cin>>a>>b;
memset(a1,0,sizeof(a1));
memset(b1,0,sizeof(b1));
s1=strlen(a);
s2=strlen(b);
for(i=s1-1,j=0;i>=0;i--,j++)
a1[i]=a[j]-48;
for(i=s2-1,j=0;i>=0;i--,j++)
b1[i]=b[j]-48;
if(s1<s2)s1=s2;
for(i=0;i<s1;i++)
{
b1[i]=a1[i]+b1[i];
b1[i+1]=b1[i+1]+b1[i]/10;
b1[i]=b1[i]%10;
}
cout<<"Case "<<n1<<":"<<endl;
cout<<a<<" + "<<b<<" = ";
if(b1[i]!=0)s1=s1+1;
for(i=s1-1;i>=0;i--)
cout<<b1[i];
if(n1==t){cout<<endl;break;}
cout<<endl<<endl;
}
return 0;
}