Skip to content

Instantly share code, notes, and snippets.

@ampulhetadosaber
Created June 29, 2019 00:27
Show Gist options
  • Save ampulhetadosaber/40ea466469137f6f27b41f9e91088235 to your computer and use it in GitHub Desktop.
Save ampulhetadosaber/40ea466469137f6f27b41f9e91088235 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
string inverso(int x){ // função que retorna o número escrito da direita pra esquerda
string retorno;
while(x!=0){
int digito = x%10; // digito é último dígito do número
retorno += digito+'0'; // retorno recebe o caractere equivalente ao inteiro digito
x/=10; // divido x por 10, ou seja, elimino o último dígito de x
}
return retorno;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment