成都创新互联网站制作重庆分公司

PalindromeNumber

class Solution {
public:
    bool isPalindrome(int x) {
        int x1=x;
        int x2=x;
        int count=0;
        int num=0;
        int sum=0;
        while(x1>0)//得到未知整数的位数
        {
            x1=x1/10;
            count++;
        }
        for(int i=0;i<=count;i++)
        {
            sum=sum*10+num;//逆置原整数
            num=x2%10;//除10取余数;
            x2=x2/10;
        }
        if(sum==x)
        return true;
        else
        return false;
    }
};

本文题目:PalindromeNumber
文章URL:http://cxhlcq.com/article/poiose.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部