Digit inversion
Time Limit: 1 s memory limit: 128 MB
[Problem description]
Given an integer, please reverse the numbers on each digit to get a new number. The new number must also satisfy the common integer form.
That is, unless the given original number is zero, the highest digit of the new number obtained after the inversion should not be zero (see example 2 ).
[Input]
The input file name is reverse. In.
Input a total of 1 rows, an integer n.
[Output]
The output file name is reverse. Out.
The output contains one row and an integer, indicating the new number after inversion.
[Input and Output Example 1]
123
-380
[Input and Output Example 2]
321
-83
[Data Scope]
-1,000,000,000 ≤ n ≤ 1,000,000,000.
This question is too simple to explain
Code:
1 # include <stdio. h> 2 int main () 3 {4 int N, f = 0, T; 5 6 scanf ("% d", & N); 7 if (n = 0) 8 {9 printf ("% d \ n", n); 10} 11 else12 {13 if (n <0) 14 {15 f = 1; // indicates that N is a negative number 16 N =-N; 17} 18 t = 0; 19 while (n> 0) 20 {21 t = n % 10 + T * 10; 22 N/= 10; 23} 24 if (F = 1) printf ("-"); 25 printf ("% d \ n", t ); 26} 27 return 0; 28}
View code
Noip2011 popularity group-digital reversal