class Solution {public: int reverse(int x) { /* 1.-x可能溢出 2.x反转后也可能溢出 */ #includeif(x==0x80000000 ) return 0; if(x<0) return -reverse(-x); string s=to_string(x); std::reverse(s.begin(),s.end()); long long int val=stoll(s); return val>0x7fffffff?0:val; }};