题目:判断是否是回文数(空间要求不能用额外的)
注意:负数不是回文数
class Solution {
public:
bool isPalindrome(int x) {
if(x<0)
return false;
int tmp=x,res=0;
while(tmp)
{
res=res*10+tmp%10;
tmp=tmp/10;
}
return x==res;
}
};