题意 代码 class Solution { public: int reverse(int x) { int falg = x > 0; x = abs(x); long long res = 0; while (x > 0) { res = res * 10 + x % 10; x /= 10; } if (res > (2ll << 31 - 1) || (res * -1 < (-1 * (2ll << 31)))) { return 0; } return falg ? res : res * -1; } }; 比较简洁