当前位置:网站首页>Palindromes (simple version)

Palindromes (simple version)

2022-06-22 22:40:00 Douglas_ LT

A daily topic ing, Today is a simple question Power button 9. Palindrome Number

class Solution {
    
public:
    bool isPalindrome(int x) {
    
        string a;
        int i=0;
        if(x<0)
        return false;
        
        while(x!=0)
        {
    
            a[i++]=x%10+'0';
            x=x/10;
        }
        for(int j=0,k=i-1;j<k;j++,k--)
        {
    
            if(a[j]!=a[k])
                return false;
        }
        return true;
    }
};
原网站

版权声明
本文为[Douglas_ LT]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221745247680.html

随机推荐