1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char a[1000],b[1000],c[1001]; 6 int T,T1; 7 scanf("%d",&T); 8 T1=T; 9 getchar(); 10 while(T--) 11 { 12 int alen,blen,clen,i,j,k=0,p=0; 13 memset(a,0,sizeof(a)); 14 memset(b,0,sizeof(b)); 15 memset(c,0,sizeof(c)); 16 scanf("%s%s",a,b); 17 alen=strlen(a),blen=strlen(b); 18 for(i=alen-1,j=blen-1;;) 19 { 20 c[k]=(a[i]+b[j]-'0'-'0'+p)%10+'0'; 21 p=(a[i]+b[j]-'0'-'0'+p)/10; 22 if(i==0&&j==0) 23 { 24 if(p>0) 25 { 26 c[++k]='1'; 27 break; 28 } 29 break; 30 } 31 if(i==0) 32 { 33 while(j>0) 34 { 35 c[++k]=(p+b[--j]-'0')%10+'0'; 36 p=(p+b[j]-'0')/10; 37 } 38 break; 39 } 40 if(j==0) 41 { 42 while(i>0) 43 { 44 c[++k]=(p+a[--i]-'0')%10+'0'; 45 p=(p+a[i]-'0')/10; 46 } 47 break; 48 } 49 i--,j--,k++; 50 } 51 printf("Case %d:\n",T1-T); 52 for(i=0;i<alen;i++) 53 printf("%c",a[i]); 54 printf(" + "); 55 for(i=0;i<blen;i++) 56 printf("%c",b[i]); 57 printf(" = "); 58 for(i=k;i>=0;i--) 59 printf("%c",c[i]); 60 if(T>0) 61 printf("\n\n"); 62 else 63 printf("\n"); 64 } 65 }