Palindrome Integer

/***
a integer is the palindrome?
***/

#include<iostream>

using namespace std;

bool ispalindrome(int x, int &y) {
       if(x == 0 || y == 0) return true;
      
       if(ispalindrome(x/10, y)) {
              if (x%10 == y%10) {
                     y /= 10;
                     return true;
              }
              else return false;
       } else return false;
}

void main() {
       int n = 135631;
       if (ispalindrome(n, n))
       {
              cout<<"is palindrome"<<endl;
       } else cout<<"no"<<endl;

}

Comments

Popular posts from this blog

Sudoku

Longest prefix matching - trie

Climbing Stairs