领扣(LeetCode)整数反转

参考了答案,不过略有改动

class Solution {
public:
     int reverse(int x) {
        long rev = 0;//定义长整形避免溢出
        int pop;
        while (x != 0) {
            pop= x % 10;
            x/=10;
            rev = rev * 10 + pop;
        }
         if(rev>INT_MAX||rev

你可能感兴趣的:(LeetCode)