[Leetcode]009.Palindrome Number

public class Solution {
    public boolean isPalindrome(int x) {
        if (x<0 || (x!=0 && x%10==0)) return false;
     
        int div = 1;  
        while(x/10>=div)  
            div *= 10;  
        while(x>0)  
        {  
            if(x/div!=x%10)  
                return false;  
            x = (x%div)/10;  
            div /= 100;  
        }  
        return true;  
    
    }
}
posted @ 2016-05-18 11:03  zhou23  阅读(86)  评论(0编辑  收藏  举报