1.题目
Determine whether an integer is a palindrome. Do this without extra space.
判断一个整数是否是回文数。
2.思路
此题so easy,负数不是回文数。直接贴代码:
class Solution {
public:
bool isPalindrome(int x) {
if(x < 0) return false;
int tmp = x;
int ans=0;
while(tmp != 0){
ans = ans*10 + tmp%10;
tmp /= 10;
}
return x == ans ?1:0;
}
};