Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
class Solution {
public:
int reverse(int x) {
int res=0;
int left;
while (x)
{
int last=x%10;
x=x/10;
res=res*10+last;
}
return res;
}
};