9. 回文数

 1 class Solution 
 2 {
 3 public:
 4     bool isPalindrome(int x) 
 5     {
 6         if(x < 0) return false;
 7         vector<int> nums;
 8         while(x)
 9         {
10             nums.push_back(x % 10);
11             x /= 10;
12         }
13         int n = nums.size();
14         for(int i = 0;i < n;i ++)
15         {
16             if(nums[i] != nums[n - i - 1]) return false;
17         }
18         return true;
19     }
20 };

 

posted @ 2020-03-15 18:20  Jinxiaobo0509  阅读(97)  评论(0)    收藏  举报