Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
class Solution { public: bool isPalindrome(int x) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. if (x < 0) return false; // or convert to positive to do the verification int div = 1; while (div <= x / 10) div *= 10; while (x != 0) { int first = x / div; int last = x % 10; if (first != last) return false; x = (x % div) / 10; div /= 100; } return true; } };
设计模式之原型模式(Prototype)摘录,布布扣,bubuko.com
设计模式之原型模式(Prototype)摘录
原文:http://blog.csdn.net/fengbingchun/article/details/24130315