public class Solution {
public boolean isPalindrome(int x) {
if( x < 0 ) return false;
int i = 1 , j = 10 ;
while( x / i >= 10 ) i *= 10 ;
int flag = i;
while( flag >1 ){
if( x/i%j != x%j ) return false;
x /= j;
i /= 100;
flag /= 100;
}
return true;
}
}
public class Solution {
public boolean isPalindrome(int x) {
if( x < 0 || x!=0 && x%10==0 ) return false;
int build = 0;
while( x > build ){
build = build * 10 + x % 10;
x /= 10;
}
return build == x || build/10 == x ;
}
}
原文:http://www.cnblogs.com/flyfatty/p/6648850.html