//反转之后判断就行了class Solution { public: bool isPalindrome(int x) { int t = x; if(x < 0) return false; int sum = 0; while(x > 0){ sum = sum*10 + x%10; x = x/10; } if(sum == t) return true; return false; } };