Created
February 10, 2012 21:05
-
-
Save felladrin/1792876 to your computer and use it in GitHub Desktop.
Invertendo os dígitos de um número inteiro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
unsigned int num; | |
unsigned int numinv; | |
cout << "Digite um número inteiro não-negativo: "; | |
cin >> num; | |
numinv = num % 10; | |
num /= 10; | |
do | |
{ | |
numinv *= 10; | |
numinv += ( num % 10 ); | |
num /= 10; | |
} | |
while ( num != 0 ); | |
cout << "O número invertido é " << numinv << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment