import java.util.*;
public class Solution {
/**
*
* @param x int整型
* @return bool布尔型
*/
public boolean isPalindrome (int x) {
if(x == 0) return true ;//0是回文
if(x < 0) return false ;//负数不是回文
int count = 1 ;//记录x的量级 例如101量级是100,15量级是10
int tmp = x ;
while(tmp / 10 != 0) {
tmp /= 10 ;
count *= 10 ;
}
int leftBase = count ;//左边基数
int rightBase = 1 ;//右边基数
while(leftBase > rightBase) {//依次取两端的数,相比较
int leftCur = x / leftBase % 10 ;
int rightCur = x / rightBase % 10 ;
if(leftCur != rightCur) {
return false ;
}
leftBase /= 10 ;
rightBase *= 10 ;
}
return true ;
}
}