简单题,求回文的整数,先额外判断一下负数都不可能为回文串,其他的作为一种考虑。
class Solution {
public:
bool isPalindrome(int x) {
int s[1000];
int cnt=0;
long long xx=x;
if(xx<0)return false;
while(xx){
s[cnt++]=xx%10;
xx/=10;
}
for(int ii=0;ii<cnt&&((2*ii)<=cnt-1);ii++){
if(s[ii]!=s[cnt-ii-1])return false;
}
return true;
}
};