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.xwwzsj.com/article/poiose.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款