[Leetcode]007. Reverse Integer

public class Solution {
    public int reverse(int x) {
        long rev=0;
        while(x!=0){
            rev = rev*10+x%10;
            x=x/10;
            if(rev > Integer.MAX_VALUE || rev < Integer.MIN_VALUE)
            return 0;
        }
        return (int) rev;

    }
}
posted @ 2016-05-15 13:51  zhou23  阅读(181)  评论(0编辑  收藏  举报