LeetCode 7

static auto io_sync_off = [](){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    return nullptr;
}();
class Solution {
public:
    int reverse(int x) {
        long result = 0;
        while (x != 0) {
            // cout << result*10 << "; "<<x%10<<endl;
            result = result * 10 + x % 10;
            if (result > INT_MAX || result < INT_MIN) return 0;
            x /= 10;
        }
        return result;
    }
};

 

posted @ 2018-09-13 09:54  一只狐狸scse  阅读(89)  评论(0)    收藏  举报