Determine whether an integer is a palindrome. Do this without extra space.
class Solution {
public:
bool isPalindrome(int x) {
int a, b, tmp;int i = 0;
a = 0;
b = (x);
while (b > 0) //负数不是回文,a=x的反转
{
tmp = a;
a *= 10;
a += b % 10;
if((a- b % 10)/10!=tmp) //越界检查
{
break;
}
b = b / 10;
i++;
}
return a == abs(x);
}
};