PalindromeNumber-大悟县灿优商贸网站建设

关于灿优商贸

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

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
文章出自:http://www.apyobr.com/article/poiose.html

其他资讯