一般都需要用base来计数,排除数字中0的影响
class Solution {
public:
bool isPalindrome(int x) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(x<0)
return false;
int base=1,right=0,left=x;
while(left>=base){
right = 10*right+left%10;
left /= 10;
base *= 10;
}
if(left==right||right/10==left)
return true;
return false;
}};