# Include <iostream>
# Include <string. h>
Using namespaceSTD ;
Int Main ( Void )
{
IntN ,AA ,Bb ,CC ,I ,J ,Count =0 ;
CharA [1002 ],B [1002 ],C [1003 ];
CIN >N ;
While (N --)
{
CIN >A >B ;
Count ++;
Cout <"Case" <Count <":" <Endl ;
Memset (C ,'0' , Sizeof (C ));// Initialize the C character array so that all elements in the array are 0. Note that '/0' must be added to the last position'
Strrev (A );// String Inversion
Strrev (B );
AA =Strlen (A );
Bb =Strlen (B );
CC = (AA > =Bb )?AA :Bb ;
For(I=0,J=0;I<AA;I++,J++)
{
C[J] =A[I];
}
For(I=0,J=0;I<Bb;I++,J++)
{
C[J] + =B[I]-'0';
}
For(I=0;I<=CC;I++)
{
If(C[I]> =58)
{
C[I] =C[I]-10;
C[I+1] ++;
}
}
If(C[CC]! ='0')
C[CC+1] ='/0';
Else
C[CC] ='/0';
Strrev(A);
Strrev(B);
Strrev(C);
If(N! =0)
Cout<A<"+"<B<"="<C<Endl<Endl;
Else
Cout<A<"+"<B<"="<C<Endl;
}
Return0;
}
I have been doing this question for a long time, because the results seem to be correct at the beginning, and the results and formats running on VC fully meet the requirements of the question, however, "Wrong answer" is true during submission ". This kind of prompt error is really speechless. In addition, I have less questions about myself a, and I have no experience. I do not know the error. Today, I suddenly want to do this. Because I saw the string inversion and initialization library functions on the Internet the day before, I felt like it was easy to do this. The result is finally accept. Very nice. I will post it for you to review! I am quite satisfied with this program.
Test data:
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample OutputCase 1:
1 + 2 = 3
Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110