給你一個整數,請反序輸出。
.......直接寫?
class Solution {
public:
    int reverse(int x) {
        int ans=0;
        while(x!=0)
        {
            if(ans>=214748365||ans<=-214748365)
                return 0;
            ans=ans*10+x%10;
            x/=10;
        }
        return ans;        
    }
};
其實本身這題根本沒什麼難度,但其實也是碰過error的。runtime error: signed integer overflow: 925935840 * 10 cannot be represented in type 'int' (solution.cpp)
簡單來說就是當 ansx10 的時候我們也不能讓她溢位,剩下就沒有問題了。