判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。
class Solution {
public boolean isPalindrome(int x) {
int res=0;
int rev=x;
while(x!=0){
int a=x%10;
x/=10;
res=res*10+a;
}
if(res==rev&&rev>=0){
return true;
}
else{
return false;
}
}
}
浙公网安备 33010602011771号