回文数

class Solution {
public:
    bool isPalindrome(int x) {
        if(x<0) return false;//排除负数
        string str_x = to_string(x);
        std::reverse(str_x.begin(),str_x.end());
        stringstream stream(str_x);
        int result;//最好将声明放在开头
        stream >> result;
        return x == result;//比较得出结果
    }
}
原文地址:https://www.cnblogs.com/pacino12134/p/10944678.html