leetcode 回文数

class Solution {
public:
    bool isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        int temp = x;
        int temp2 = 0;
        while(temp) {
            temp2 = temp2*10 + temp%10;
            temp/=10;
        }
        return temp2 == x;
    }
};

你可能感兴趣的:(leetcode)