1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
class { public: bool isPalindrome(int x) { if(x < 0) return false; int d = 1; while(x/d >= 10) d *= 10; while(x > 0) { int left = x / d; int right = x % 10; if(left != right) { return false; } x = x % d / 10; d = d / 100; } return true; } };
|
近期评论