【leetcode】9. Palindrome Number

题目描述:

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

解题分析:

^_^个人觉得这道题没有什么可分析的,直接看代码就能明白^_^.

具体代码:

 1 public class Solution {
 2     public static boolean isPalindrome(int x) {
 3         if(x<0)
 4             return false;
 5         if(x>=0&x<=9)
 6             return true;
 7         int n=x;
 8         int sum=0;
 9         while(n!=0){
10             int num1=n%10;
11             int num2=n/10;
12             sum=sum*10+num1;
13             n=num2;
14         }
15         if(sum==x){
16             return true;
17         }
18         return false;
19     }
20 }

 

posted @ 2016-06-08 01:01  godlei  阅读(181)  评论(0编辑  收藏  举报