LeetCode 9 Palindrome Number

题目

c++

class Solution {
public:
    int a[100005];
    bool isPalindrome(int x) {
        
        if(x<0)
            return false;
        
        
        int pos=0;
        while(x)
        {
            a[pos++]=x%10;
            x/=10;
        }
        
        for(int i=0,j=pos-1;i<j;i++,j--)
        {
            if(a[i]!=a[j])
            {
                return false;
            }
        }
        
        return true;
        
    }
};
posted @ 2019-06-17 08:46  Shendu.CC  阅读(99)  评论(0编辑  收藏  举报