反转int,如果越界则返回0

int reverse(int x)
{
    if (x == (0x1<<31))
        return 0;

    int flag = 1;
    x >= 0 ? flag : (flag = -1, x = -x);

    int yu = 0;
    int _x = 0;

    while (x) {
        yu = x%10;
        _x = _x *10 + yu;
        x/=10;
    }

  return _x*flag;
}