9. Palindrome Number

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     }

 

posted @ 2017-10-20 19:32  daniel456  阅读(89)  评论(0编辑  收藏  举报