欧美1区2区3区激情无套,两个女人互添下身视频在线观看,久久av无码精品人妻系列,久久精品噜噜噜成人,末发育娇小性色xxxx

翻轉(zhuǎn)數(shù)字

數(shù)字反轉(zhuǎn)?:給定整數(shù) x,返回其反轉(zhuǎn)后的結(jié)果(如 123 → 321,注意處理負(fù)數(shù)及溢出)

    int main()
    {
        const int num = -2147483641; //(-2147483647 - 1)
        printf("%d\n", num);
        long long temp = num;

        vector<unsigned int> vec;
        if (0 == temp)
            vec.push_back(0);

        bool sign = false;
        if (temp < 0)
        {
            temp = -temp;
            sign = true;
        }

        while (temp != 0)
        {
            vec.push_back(temp % 10);
            temp = temp / 10;
        }

        //[3, 2, 1] = > 321
        temp = 0;
        for (int i = 0; i < vec.size(); i++)
        {
            temp = temp * 10 + vec[i];
            if (sign && -temp < INT_MIN)
            {
                printf("%d\n", 0);
                return 0;
            }
            if (!sign && temp > INT_MAX)
            {
                printf("%d\n", 0);
                return 0;
            }
        }

        if (sign)
        {
            temp = -temp;
        }

        const int result = static_cast<int>(temp);
        printf("%d\n", result);

        return 0;
    }

全部評論

相關(guān)推薦

評論
點(diǎn)贊
收藏
分享

創(chuàng)作者周榜

更多
??途W(wǎng)
牛客企業(yè)服務(wù)