leetcode009

class Solution {
public:
    bool isPalindrome(int x) {
        if( x<0 )
            return false;
        int div=1;
        int  low= 0, high = 0;
        int y=x;
        while( x/div >= 10 )
            div *= 10;

        while( x ){
            low = x % 10;
            high = x / div;

            if( low != high )
                return false;
            x = ( x % div ) / 10;
            div = div / 100;
        }
        return true;
    }
};

你可能感兴趣的:(数据结构,leetcode)