思路一:先使用vector容器存下每一位的数据,在判断容器里面首尾是否相等
class Solution { public: bool isPalindrome(int x) { if(x<0) return false; vector<int> data; while(x!=0){ int temp = x%10; x = x/10; data.push_back(temp); } int start = 0,end=data.size()-1; while(start<end){ if(data[start]!=data[end]){ return false; } start++; end--; } return true; } };