力扣-9题 回文数(C++)

题目链接:https://leetcode-cn.com/problems/palindrome-number/
题目如下:
在这里插入图片描述
在这里插入图片描述

class Solution {
    
    
public:
    bool isPalindrome(int x) {
    
    
        if(x<0) return false;

        long long y=0;
        int x_1=x;
        while(x!=0){
    
    
            int temp=x%10;
            x=x/10;
            y=y*10+temp;
        }

        return x_1==y;
    }
};

おすすめ

転載: blog.csdn.net/qq_40467670/article/details/121262004