码迷,mamicode.com
首页 > 其他好文 > 详细

Palindrome Number

时间:2015-12-18 18:20:48      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

Palindrome Number

Total Accepted: 95552 Total Submissions: 318732 Difficulty: Easy

 

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

 

class Solution {
public:
    bool isPalindrome(int x) {
        int y   = 0;
        int tmp = x;
        while(tmp){
            y   = y*10+tmp%10;
            tmp = tmp/10;
        }
        
        return x>=0 && y==x ;
    }
};

 

Palindrome Number

标签:

原文地址:http://www.cnblogs.com/zengzy/p/5057552.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!