
class Solution {public:int reverse(int x) {int re;string s = to_string(x);auto l = s.begin();auto r = prev(s.end());if(*l==‘-‘)l++;while(l<r){char temp = *l;*l = *r;*r = temp;l++;r--;}try{re = stoi(s);}catch(exception e){re = 0;}return re;}};
原文:http://www.cnblogs.com/zhuzhenfeng/p/6b2e5781004566ff6ca9bdddfb765948.html