Noip2011 popularity group-digital reversal

Source: Internet
Author: User

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

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.