[Plain] 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.
Input
Input 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.
Output
For each test case, you shoshould output its reverse number, one case per line.
Sample Input
3
12
-12
1200
Sample Output
21
-21
2100
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.
Input
Input 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.
Output
For each test case, you shoshould output its reverse number, one case per line.
Sample Input
3
12
-12
1200
Sample Output
21
-21
2100
[Plain] <PRE class = plain name = "code"> # include <stdio. h>
Int main ()
{
Int I;
Int j;
Int n;
Int tab; // indicates whether there is zero at the end of the tag.
Int num;
Int flag; // indicates whether the flag is a positive or negative number.
Int count;
Int array [100]; // stores values.
Scanf ("% d", & n );
While (n --)
{
Scanf ("% d", & num );
J = 0;
Tab = 1; // assume there is zero at the end
Flag = 1; // positive number is 1
Count = 0;
If (num <0)
{
Flag = 0; // negative
Num =-1 * num;
}
While (num)
{
If (num % 10 = 0 & tab! = 0)
{
Count ++; // calculates the number of zeros.
}
Else
{
Array [j ++] = num % 10;
Tab = 0;
}
Num/= 10;
}
If (flag = 0)
{
Printf ("-");
}
For (I = 0; I <j; I ++)
{
Printf ("% d", array [I]);
}
For (I = 0; I <count; I ++) // print the number of zeros at the end
{
Printf ("0 ");
}
If (n> 0)
{
Printf ("\ n ");
}
}
Return 0;
}
</PRE> <BR>
<BR>
<PRE> </PRE>
<P> </P>
<PRE> </PRE>
<PRE> </PRE>