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 ;
}