Hey, everyone, I did it like this in cplusplus, and it worked

```
class Solution {
public:
int reverse(int x) {
long result = 0;
while (x != 0)
{
result = result*10 + x%10;
x /= 10;
}
if (x < 0) result *= -1;
return (int)(result < INT_MIN || result > INT_MAX)?0:result;
}
};
```