-
#include <stdio.h>
#include <string.h>int main()
{
//freopen("a.txt","r",stdin);
//freopen("b.txt","w",stdout);
char a[1000],b[1000];
int result[1000];
int i,t,alen,blen;
scanf("%d",&t);
for (i=1;i<=t;i++)
{
int res=0,total,j=-1,k;
if (i>1) putchar(10);
printf("Case %d:\n",i);
scanf("%s%s",a,b);
alen=strlen(a)-1;
blen=strlen(b)-1;
while (alen>=0||blen>=0)
{
int an,bn;
if (alen>=0) an=a[alen]-48;
else an=0;
if (blen>=0) bn=b[blen]-48;
else bn=0;
total=an+bn+res;
res=total/10;
result[++j]=total%10;
alen--;
blen--;
}
printf("%s + %s = ",a,b);
if (res) printf("%d",res);
//while (result[j]==0) j--;
for (k=j;k>=0;k--)
printf("%d",result[k]);
putchar(10);
}
return 0;
}
大数相加
最新推荐文章于 2024-11-03 15:50:06 发布