Advertisement
DimasDark

Palindromo fixed

May 25th, 2013
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. //programa para verificar se num numero de ate 4 casas é palindromo ou não
  4. bool ePalin(int digitado)
  5. {
  6.     bool palindromo = false;
  7.     int num = digitado;
  8.     int invertido = 0;
  9.     while(num != 0)
  10.     {
  11.         int digito = num % 10;
  12.         invertido = (invertido * 10) + digito;
  13.         num = num / 10;
  14.     }
  15.     if (digitado == invertido)
  16.         palindromo = true;
  17.     return palindromo;
  18. }
  19.  
  20. int main()
  21. {
  22.     for(int i=1; i<100; i++)
  23.     {
  24.         if(ePalin(i))
  25.         {
  26.             cout<<i<<"\n";
  27.         }
  28.     }
  29.  
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement