HDU 1266 reverse number (simple question)

Source: Internet
Author: User
Reverse number

Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 2047 accepted submission (s): 926

Problem descriptionwelcome to 2006 '4 computer college programming contest!

Specially, I give my best regards to all freshmen! You are the future of hdu acm! And now, I must tell you that ACM problems are always not so easy, but, cannot this one... Ha-ha!

Give you an integer; your task is to output its reverse number. Here, reverse number is defined as follows:
1. The reverse number of a positive integer ending without 0 is General reverse, for example, reverse (12) = 21;
2. The reverse number of a negative integer is negative, for example, reverse (-12) =-21;
3. The reverse number of an integer ending with 0 is described as example, reverse (1200) = 2100.

Inputinput file contains multiple test cases. There is a positive integer n (n <100) In the first line, which means the number of test cases, and then N 32-bit integers follow.

Outputfor each test case, You shoshould output its reverse number, one case per line.

Sample input3
12
-12
1200

Sample output21
-21
2100

Authorlcy

Sourcehdu 2006-4 Programming Contest

Recommendlxj
 /*  
HDU 1266
Water question, but it should be stored using strings, not Integer as the question says
Large Data
*/
# Include < Stdio. h >
# Include < String . H >
Int Main ()
{
Char M [ 100 ];
Long Long X;
Int T, I;
Int T;
Scanf ( " % D " , & T );
While (T -- )
{
Scanf ( " % S " , & M );
Int K = Strlen (m );
For (T = K - 1 ; T > = 0 ; T -- )
If (M [T] ! = ' 0 ' ) Break ;
If (M [ 0 ] = ' - ' )
{
Printf ( " - " );
For (I = T; I > = 1 ; I -- )
Printf ( " % C " , M [I]);
For (I = T + 1 ; I < K; I ++ )
Printf ( " 0 " );
}
Else
{

For (I = T; I > = 0 ; I -- )
Printf ( " % C " , M [I]);
For (I = T + 1 ; I < K; I ++ )
Printf ( " 0 " );
}
Printf ( " \ N " );
}
Return 0 ;
}
Related Article

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.