题意是 Sample Input
2 1 2 112233445566778899 998877665544332211
Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin>>n;
int nn=1;
while(n--)
{
string add(string x,string y);
string x,y;
cin>>x>>y;
if(n>=1)
{
cout<<"Case "<<nn<<":"<<endl;
cout<<x<<" "<<"+"<<" "<<y<<" "<<"="<<" "<<add(x,y)<<endl;
cout<<endl;
}
else
{
cout<<"Case "<<nn<<":"<<endl;
cout<<x<<" "<<"+"<<" "<<y<<" "<<"="<<" "<<add(x,y)<<endl;
}
nn++;
}
return 0;
}
string add(string x,string y)
{
if(x.length()<y.length())
{
string temp=x;
x=y;
y=temp;
}
int g=0;
for(int i=x.length()-1,j=y.length()-1;i>=0;i--,j--)
{
if(j>=0)
{
x[i]=char(x[i]+y[j]-'0'+g);
}
else
{
x[i]=char(x[i]+0);
}
if(x[i]-'0'>=10)
{
x[i]=char((x[i]-'0')%10+'0');
g=(x[i]-'0')/10;
}
}
return x;
}