leetcode reverse integer&&Palindrome Number

public class Solution {
public int reverse(int x) {
int ret=0;
while(x!=0)
{
int t=x%10;
ret=ret*10+t;
x=x/10;


}


return ret;

}
}

public class Solution {

    public boolean isPalindrome(int x) {

        if(x<0) return false;

        if(x==0) return true;

        int ret=0;

        int xold=x;

        while(x!=0)

        {

           int temp= x%10; // zui hou yi wei

           ret=ret*10+temp;

          

           x=x/10;

           

            

            

        }

        

    

        if(ret==xold) return true;

        return false;

        

    }

}

 

你可能感兴趣的:(LeetCode)