9. 回文数

水题~。

注意点

需要一个临时变量存储(x)原始的值。

class Solution {
public:
    bool isPalindrome(int x) {
        if(x < 0) return false;
        long long res = 0;
        int t = x;
        while(x)
        {
            res = res * 10 + x % 10;
            x /= 10;
        }
        return res == t;
    }
};
原文地址:https://www.cnblogs.com/fxh0707/p/14929420.html