9. Palindrome Number

class Solution {
public:
    bool isPalindrome(int x) {
    vector<int> tmp;
    int y;
    if(x<0)
        return false;
    y=x;
    cout<<y<<endl;
    int count=0;
    while(y!=0)
    {
        tmp.push_back(y%10); 
        cout<<y%10<<endl;
        count++;
        y=y/10;       
    }
    int i=0,j=count-1;
    while(i<j)
    {
        if(tmp[i]!=tmp[j])
            return false;
        i++;
        j--;
    }
    return true;
    }
};

  

posted @ 2017-12-14 20:30  PirateLHX  阅读(149)  评论(0编辑  收藏  举报