如果是负数, 打上标记, 再把数字转换成字符串, 反转, 再转换成整数
class Solution { public: int reverse(int x) { int f = 0; if ( x < 0) { x = -x; f = 1; } string str = to_string(x); string s; for ( int i = str.size()-1; i >= 0; i--) s.push_back(str[i]); int xx = stoi(s); if ( f == 1) return -xx; return xx; } };