标签:
public class Solution { public boolean isPalindrome(int x) { if(x < 0) return false; if(x < 10) return true; int i = 1; int tmpx = x; while(tmpx/10 != 0) { i *= 10; tmpx /= 10; } while(x != 0) { int left = x % 10; int right = x / i; if(left != right) return false; else { x = (x%i)/10;//x%i 去头 (x%i)/10去尾 i /= 100;//少了两个数字,位数少2 } } return true; } }
标签:
原文地址:http://www.cnblogs.com/zyqBlog/p/5966525.html