06_ Palindrome Number

题目点我查看~……~

/*
 注意负数不被看作回文数
*/
class Solution {
public:
    bool isPalindrome(int x) {
        int str[30];
        int  cur=0;
        if(x<0){
            return false;
        }
        
        while(x!=0){
            str[cur++]=x%10;
            x/=10;
        }
        
        for(int i=0;i<cur/2;i++){
            if(str[i]!=str[cur-i-1]){
                return false;
            }
        }
        return true;
        
    }
};


posted on 2016-07-07 22:21  胖胖的乓乓  阅读(101)  评论(0编辑  收藏  举报

导航