class Solution {
public:
bool isPalindrome(int x) {
if(x<0)
return false;
int xx = x;
int count = 0;
while(xx!=0)
{
++count;
xx/=10;
}
xx = x;
while(count>1)
{
int a = xx%10;
int tmp = ((int)pow(10.0,count-1));
int b = xx/tmp;
xx = (xx%tmp)/10;
if(a!=b)
return false;
count-=2;
}
return true;
}
};
9 Palindrome Number
最新推荐文章于 2022-03-10 15:20:06 发布