9. Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.

就是判断 反转后的整数和反转之前的整数是否相等

class Solution {  
public:  
    bool isPalindrome(int x) {
        if ((x % 10 == 0) && (x != 0)) return false;
        int tmp = x;
        int y = 0;
        if (x < 0) return false;
        while(tmp > 0) {
            y *= 10;
            y += tmp % 10;
            tmp /= 10;
        }
        return x == y;
    } 
};  
原文地址:https://www.cnblogs.com/pk28/p/7196328.html