A question about C Language Input

Source: Internet
Author: User

# Include <iostream>
# Include <string. h>
Using namespaceSTD ;
Int
Main ( Void )
{

Int
N ,AA ,Bb ,CC ,I ,J ,Count =0 ;
Char
A [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;

}
Return
0;
}

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.