class Solution {
public:
bool isPalindrome(int x) {
if (x < 0 || (x % 10 == 0 && x != 0)) {
return false;
}
int a = 0;
while (x > a) {
a = a * 10 + x % 10;
x /= 10;
}
if(x==a)
return true;
if((a/10)==x)
return true;
else
return false;
}
};
打卡5(回文数)
最新推荐文章于 2021-07-22 14:54:35 发布