leetcode 9:回文数

bool isPalindrome(int x) {
        vector<int> a;
        if(x<0)
            return false;
        if(x==0)
            return true;
        if(x>0){
            while(x/10!=0){
                a.push_back(x%10);
                x=x/10;
            }
            a.push_back(x%10);
            
            int len=a.size();
            for(int i=0;i<len/2;i++){
                if(a[i]!=a[len-i-1])
                    return false;
            }
            return true;
        }
    }

 

相关文章: