leetCode7

int reverse(int x)
{
    long long re = x;
    long long MaxInt = 2147483647;
    long long MinInt = 2147483648;
    int op = 0;
    if(re<0)
    {
        op = 1;
        re = -re;
    }
    vectorss;
    while(re)
    {
        int r = re%10;
        re/=10;
        ss.push_back(r);
    }
    long long sum = 0;
    for(int i = 0; iMaxInt) || (op && sum >MinInt))
        {
            sum = 0;
            break;
        }
    }
    if(op) sum = -sum;
    return sum;
}

 

你可能感兴趣的:(leetcode)