ACM的题,程序对了的话会有追加悬赏哟~DescriptionCalculate a + b.InputThe input will consist of a series of pairs of integers a and b(0
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 10:18:57
ACM的题,程序对了的话会有追加悬赏哟~DescriptionCalculate a + b.InputThe input will consist of a series of pairs of integers a and b(0
ACM的题,程序对了的话会有追加悬赏哟~
DescriptionCalculate a + b.
InputThe input will consist of a series of pairs of integers a and b(0
ACM的题,程序对了的话会有追加悬赏哟~DescriptionCalculate a + b.InputThe input will consist of a series of pairs of integers a and b(0
#include
#include
int main()
{
int i,t,j=1,n,len,k;
char sum[1009],sa[1009],sb[1009];
//scanf("%d",&t);
//getchar();
while(scanf("%s%s",sa,sb)!=EOF)
{
for(i=0;i=0;i--,k++)
{
sum[k]=sum[k]-'0'+sa[i];
n=k;
while(sum[n]>'9')
{
sum[n+1]=sum[n+1]+(sum[n]-'0')/10;
sum[n]=(sum[n]-'0')%10+'0';
n++;
}
}
len=strlen(sb);
for(i=len-1,k=0;i>=0;k++,i--)
{
sum[k]=sum[k]-'0'+sb[i];
n=k;
while(sum[n]>'9')
{
sum[n+1]=sum[n+1]+(sum[n]-'0')/10;
sum[n]=(sum[n]-'0')%10+'0';
n++;
}
}
printf("Case %d:\n%s + %s = ",j,sa,sb);
j++;
for(i=1008;sum[i]=='0';i--);
for(;i>=0;i--)
printf("%c",sum[i]);
printf("\n");
// if(t>0)
//printf("\n");
}
return 0;
}