Palindrome Number

 

    bool isPalindrome(int x) {
        // Note: The Solution object is instantiated only once and is reused by each test case.
       if(x<0)
            return false;
        
        
        int div = 1;
        while(x/div>=10)
        {
            div*=10;
        }
        
        while(x)
        {
            int a = x/div;
            int b = x%10;
            if(a!=b)
                return false;
            x = (x%div)/10;
            div = div/100;
        }
        return true;
    }

 

posted @ 2013-10-06 09:48  summer_zhou  阅读(102)  评论(0编辑  收藏  举报