#include<iostream>
#include<cctype>
using namespace std;
const int WEISHU=200;
int main()
{
short int first[WEISHU]={0}; //储存第一个加数
short int second[WEISHU]={0}; //储存第二个加数
short int addnum[WEISHU+1]={0}; //储存两个加数的和
char ch;
char pp;
int a,b,c;
a=b=c=0;
short int i=0;
cout<<"Input the first number: "<<endl;
while(cin.get(ch)&&ch!='\n'&&isdigit(ch)) //输入字符数字并转化为整形数字
{
a++;
first[i]=short int(ch)-48;
i++;
}
i=0;
cout<<"\nInput the second number: "<<endl;
while(cin.get(pp)&&pp!='\n') //输入字符数字并转化为整形数字
{
b++;
second[i]=int(pp)-48;
i++;
}
//cout<<first[4]<<"cdasdfasdf"<<endl;
//cout<<"a= "<<a<<" b= "<<b<<endl;
c=(a>b)? a:b; // 计算最大的加数位数
//cout<<c<<endl;
cout<<"\n计算结果如下:"<<endl;
short int temp;
for(i=0;i<WEISHU;i++)
{
temp=first[i]+second[i]; //将结果储存在临时变量中
if(temp>=10) //如果相加结果大于10,进一位
{
addnum[i]+=temp%10;
addnum[i+1]=1;
}
else if(temp<10) //不大于10,则等于本身
addnum[i]+=temp;
}
/*************************结果输出***********************************/
if(addnum[c]>0)
{
for(i=c;i>=0;i--)
cout<<addnum[i];
}
else
{
for(i=c-1;i>=0;i--)
cout<<addnum[i];
}
return 0;
}