Reverse Number without extra spacespa
class Solution { public: bool isPalindrome(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function if (x < 0) { return false; } int y = x, w; for (w = 1; y > 9; y /= 10, w *= 10) ; for (;w > 1; w /= 100) { //去掉2位全部 w/=100 if (x % 10 != x / w) { return false; } x %= w; //去掉最高位 x /= 10; //去掉最低位 } return true; } };