暂时不考虑溢出的问题。
class Solution {
public:
int reverse(int x) {
int result = 0;
while(x != 0) {
result *= 10;
result += x % 10;
x /= 10;
}
if (x < 0) {
result *= -1;
}
return result;
}
};