Leetcode 9 Palindrome Number 数论

判断一个数是否是回文数

方法是将数回转,看回转的数和原数是否相同

 1 class Solution {
 2 public:
 3     bool isPalindrome(int x) {
 4         if(x < 0) return false;
 5         int _x = 0 ;
 6         int n = x;
 7         for(; x; x/= 10){
 8             _x = _x * 10 + x%10;
 9         }
10         return n == _x;
11     }
12 };
原文地址:https://www.cnblogs.com/onlyac/p/5251784.html