Palindrome Number(回文数字)
Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.
每次对比最高位和最低位
bool isPalindrome(int x) { if(x < 0) return false; int base = 1; while(x/base >= 10) base = base*10; while(x){ int leftdigit = x/base; int rightdigit = x%10; if(leftdigit != rightdigit) return false; x -= leftdigit*base; x = x/10; base = base/100; } return true; }