Palindrome Number(回文数字)
2015-03-27 09:38
176 查看
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; }
相关文章推荐
- 2. 编写一个Java应用程序,用户从键盘输入一个1~9999之间的数,程序将判断这个数是几位数,并判断这个数是否是回文数。回文数是指将该数含有的数字逆序排列后得到的数和原数相同,例如12121、32
- 数字哑谜和回文
- 判断是否是回文数字或者回文字符串
- 回文数字
- 蓝桥杯历届试题 回文数字
- 回文数字提取(PHP)
- 历届试题 回文数字
- 历届试题 回文数字 (暴力)
- 蓝桥杯历届试题 回文数字
- 回文数字的三种解法
- N回文数字(简单)
- 2013蓝桥杯-回文数字-java
- 判断是否是回文数字的函数(java)
- 蓝桥杯 历届试题 回文数字
- 【LeetCode008-009算法/编程练习C++】string转int(atoi),判断数字是否是回文
- Lettcode_9_Palindrome Number ——判断一个数字是否回文(不能申请额外空间)
- 回文数字
- 回文数,求数字的和
- 历届试题 回文数字
- 回文数字判断(递归版本)