class Solution { public: /** * * @param x int整型 * @return int整型 */ int reverse(int x) { // write code here int res = 0; while (x != 0) { int t = x % 10; x /= 10; if (res > INT_MAX / 10 ) return 0; if (res < INT_MIN / 10 ) return 0; res = res * 10 + t; } return res; } };