标签:
class Solution { public: int reverse(int x) { int flag = 1; long long x1 = x; if(x1 < 0) { flag = -1; x1 = 0-x1; } int remaind; long long result=0; while(x1){ remaind = x1%10; x1 = x1 /10; result = result*10 + remaind ; } if(flag > 0 && result > 2147483647) return 0; if(flag<0 && result > 2147483648) return 0; return flag < 0? -result:result; } };
注意溢出问题
标签:
原文地址:http://www.cnblogs.com/chdxiaoming/p/4342651.html