Skip to content

Instantly share code, notes, and snippets.

@felladrin
Created February 10, 2012 21:05
Show Gist options
  • Save felladrin/1792876 to your computer and use it in GitHub Desktop.
Save felladrin/1792876 to your computer and use it in GitHub Desktop.
Invertendo os dígitos de um número inteiro
#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