Leetcode 9

//反转之后判断就行了
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; } };

猜你喜欢

转载自www.cnblogs.com/cunyusup/p/9613263.html