leetcode 7 Reverse Integer

2018-06-04 11:56:45 浏览数 (1)

代码语言:javascript复制
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;
    }
};

0 人点赞