https://leetcode.com/problems/reverse-integer/
翻转数字:123--->321, -123--->-321,overflow就返回0
如果overflow的话就不可逆
public class Solution {
public int reverse(int x) {
int res = 0;
while (x != 0) {
int newRes = res * 10 + x % 10;
if ((newRes - x % 10) / 10 != res) {
return 0;
}
res = newRes;
x /= 10;
}
return res;
}
}