首页 > 代码库 > leetcode 7 Reverse Integer

leetcode 7 Reverse Integer

class Solution {
public:
    int reverse(int x) {
        int res = 0;
        while (x != 0) {
            int t = res * 10 + x % 10;
            if (t / 10 != res) return 0;
            res = t;
            x /= 10;
        }
        return res;
    }
};

leetcode 7 Reverse Integer