POJ29: Digital reverse

Description
Given an integer, the number of the digital please obtained by inverting each bit of a new number. The new number should also meet common form of integers that, unless given the original number is zero, otherwise obtained by inverting the highest digit of the new number should not be zero (see sample 2).

Total input line, an integer N.

-1,000,000,000 ≤ N≤ 1,000,000,000. Total output line, an integer, the number of the new inversion represents.

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long N, re_N=0;
	cin >> N;
	while (N!=0)
	{
		re_N = re_N * 10 + N % 10;
		N /= 10;
	}
	cout << re_N;
	return 0;
}
Published 16 original articles · won praise 3 · Views 236

Guess you like

Origin blog.csdn.net/bajiaoyu517/article/details/104066173