1-5-29: Digital Inversion

Source: Internet
Author: User

Total time limit:
1000ms
Memory Limit:
65536kB
Describe

Given an integer, invert the number on each bit to get a new number. The new number should also satisfy the common form of integers, that is, unless the given original number is zero, the maximum number of new numbers to be reversed should not be 0 (see Example 2).

Input
Enter a total of 1 rows, an integer n.

-1,000,000,000≤n≤1,000,000,000.
Output
outputs a total of 1 rows, an integer representing the new number after reversal.
Sample input
Example #1:123 Sample #2:380
Sample output
Example #1:321 Sample #2:83
Source
The
first problem of the popularization group of NOIP2011
#include <stdio.h>#include<string.h>intMain () {intlen=0, I; Chara[ -];    Gets (a); Len=strlen (a); inttop; Top=len-1;  while(a[top]=='0') Top--; if(a[0]=='-') {printf ("-");  for(i=top;i>0; i--) printf ("%c", A[i]); }    Else     {         for(i=top;i>=0; i--) printf ("%c", A[i]); }return 0;}

1-5-29: Digital Inversion

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.