import java.util.*; public class Solution { /** * * @param x int整型 * @return int整型 */ public int reverse (int x) { int res = 0 ; while(x != 0) { int add_num = x % 10 ; if(res > Integer.MAX_VALUE / 10 || (res == Integer.MAX_VALUE && add_num > 7)) return 0 ; if(res < Integer.MIN_VALUE / 10 || (res == Integer.MIN_VALUE && add_num > 8)) return 0; res = res * 10 + add_num ; x /= 10 ; } return res ; } }