1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

bool IsPalindrome(int n)
{
    if (n == 0)return true;
    if (n <0)return false;
    if (n%10 == 0) return false;
     
    int t = 0;
    while(n > t)
    {
        t = t*10 + n%10;
        n/=10;
    }

    if (t>n) return t/10 == n;
    
    //else if(t == n)
    return true;
}

#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    int v;

    while( cin>>v)
        cout<< v << " is" << (IsPalindrome(v)?"":" not") << " Palindrome Number."<<endl;
    return 0;
}
View Program Text


Test Status