LeetCode 9. Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.

程序代码:

bool isPalindrome(int x) {
    if(x<0)
        return false;
    else if(x<10)
        return true;
    else
    {
        int bit = (int)log10(x)+1;
        while(bit>0)
        {
            if(x%10!=x/((int)pow(10,bit-1)))
            {
                return false;
            }
            else 
            {
                x = x%((int)pow(10,bit-1));
                x/=10;
                bit -= 2;
            }

        }

    }
    return true;
}
全部评论

相关推荐

joecii:如果没有工资,那可能没有工资是这家公司最小的问题了
找实习记录
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务