leetcode7. 整数反转

class Solution {
public:
    int reverse(int x) {
        long long ans1=2147483647;
        long long ans2=-2147483648;
        int fg=0;
        long long x1=(long long)x;
        if(x1<0) fg=1,x1=-x1;
        long long t=0;
        while(x1!=0)
        {
            int cont=x1%10;
            t=t*10+cont;
            x1/=10;
        }
        if(fg) t=-t;
        if(fg)
        {
            if(tans1) return 0;
            else return t;
        }
    }
};

 

你可能感兴趣的:(Leetcode)