OneDrain

Untitled

Sep 10th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool palindrom(int n)
  6. {
  7.     int c, im = 0;
  8.     int copien = n;
  9.  
  10.     do
  11.     {
  12.         c = copien%10;
  13.         im = im * 10 + c;
  14.         copien = copien / 10;
  15.     }
  16.     while(copien != 0);
  17.     if(im == n)
  18.         return 1;
  19.     else
  20.         return 0;
  21. }
  22.  
  23. int main()
  24. {
  25.     cout << palindrom(123) << endl;
  26.     cout << palindrom(121) << endl;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment