标签:style blog color io div amp log leetcode
关键:如何取最高位的数?
1 class Solution { 2 public: 3 bool isPalindrome(int x) { 4 if(x < 0) 5 return false; 6 int div = 1; 7 int xorg = x; 8 while(x >= 10) 9 { 10 div = div*10; 11 x = x/10; 12 } 13 x = xorg; 14 while(x > 0 && div>0) 15 { 16 int r = x%10; 17 int l = x/div; 18 if(l != r) 19 { 20 return false; 21 } 22 x = (x%div)/10; 23 div = div/100; 24 } 25 return true; 26 } 27 };
LeetCode--Palindrome Number,布布扣,bubuko.com
标签:style blog color io div amp log leetcode
原文地址:http://www.cnblogs.com/cane/p/3884756.html