網址:https://leetcode.com/problems/string-to-integer-atoi/
題意:
字符串轉int數
分析:
經典題,主要需要注意輸入中,允許先有空格,再來內容.
內容可能還不是整齊和規則的...
解法:
1.遍歷空格
2.判斷正負號
3.讀數字
4.可能存在結尾號
代碼:
https://github.com/LiLane/leetcode/blob/master/java/008-StringtoInteger(atoi)⑵01504292346.java
https://github.com/LiLane/leetcode/blob/master/c%2B%2B/008-StringtoInteger(atoi)⑵01504292346.cpp