#include <stdio.h>
#include <string.h>
#define M 505
int main(void)
{
char a[M],b[M],result[M];
scanf("%s %s",a,b);
int lena = strlen(a)-1;
int lenb = strlen(b)-1;
int count=0;
int ta=0,tb=0,tc=0;
int tmp=0;
do
{
ta = (lena>=0?a[lena--]-'0':0);
tb = (lenb>=0?b[lenb--]-'0':0);
tc = tc + ta + tb;
tmp = tc%10;
if(tc>9)
{
tc /= 10;
}
else
{
tc = 0;
}
result[count++] = tmp+'0';
}while(lena>=0||lenb>=0);
for(;count>0;)
{
putchar(result[--count]);
}
putchar('\n');
return 0;
}
给出两个正整数A和B,计算A+B的值。保证A和B的位数不超过500位
最新推荐文章于 2024-07-14 00:57:23 发布