码迷,mamicode.com
首页 > 其他好文 > 详细

9. Palindrome Number

时间:2017-10-20 21:44:22      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:without   log   class   determine   rmi   term   whether   lin   out   

Determine whether an integer is a palindrome. Do this without extra space.

题目含义:不要使用额外空间,判断整数是否为回文

 

1     public boolean isPalindrome(int x) {
2         int rev = 0;
3         int y=x;
4         while (y>0){
5             rev = rev*10 + y%10;
6             y = y/10;
7         }
8         return x==rev;      
9     }

 

9. Palindrome Number

标签:without   log   class   determine   rmi   term   whether   lin   out   

原文地址:http://www.cnblogs.com/wzj4858/p/7701191.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!