class Solution {
  public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param x string字符串
     * @return bool布尔型
     */
    bool judge(string s) {
        int ls = s.size();
        int l = 0, r = ls - 1;
        while (l <= r) {
            if (s[l] != s[r])
                return false;
            l++;
            r--;
        }
        return true;
    }
    bool isPalindromeNumber(string x) {
        // write code here
        int ls = x.size();
        int flag1 = 0, flag2 = 0;
        string s1 = "", s2 = "";
        int ans;
        for (int i = 0; i < ls; ++i) {
            if (x[i] == '0' && flag1 == 0) {
                continue;
            } else if (x[i] == '.') {
                ans = i;
                break;
            } else {
                s1 += x[i];
                flag1 = 1;
            }
        }
        for (int i = ls - 1; i > ans; --i) {
            if (x[i] == '0' && flag2 == 0) {
                continue;
            } else {
                s2 += x[i];
                flag2 = 1;
            }
        }
        //cout<<s1<<' '<<s2<<endl;
        if (judge(s1) && judge(s2))
            return true;
        else
            return false;;
    }
};

一、题目考察的知识点

模拟

二、题目解答方法的文字分析

算是一个稍微大一点的模拟了

以小数点为分界线

先去掉前导零然后把它放进一个字符串里面

然后把后导零去掉,记录到另一个字符串里面

然后写一个判断回文字符串的函数分别判断之前记录下来的两个字符串,只有俩个字符串都是回文才是true

三、本题解析所用的编程语言

c++