LeetCode-9 回文数

  • C++
class Solution {
public:
    bool isPalindrome(int x) {
        if(x < 0){
            return false;
        }
        int temp = x;
        int y = 0;
        while(temp > 0){
            y *= 10;
            y += temp % 10;
            temp /= 10;
        }
        return (x == y)? true:false;
    }
};

猜你喜欢

转载自blog.csdn.net/lolimostlovely/article/details/82995676