07_Reverse Integer
1.Question

2.Solution
public class Solution { public int reverse(int x) { if (x == 0) return 0; int res = 0; int sign = 1; if (x < 0) { sign = -1; x = -1 * x; } while (x != 0) { if (res > (Integer.MAX_VALUE - x % 10) / 10) { return 0; } res = res * 10 + x % 10; x = x / 10; } return res * sign; } }
3.Test

    http://www.cnblogs.com/makexu/

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号