码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode]-007-String to Integer (atoi)

时间:2015-04-30 01:06:40      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

网址:https://leetcode.com/problems/string-to-integer-atoi/

题意:

字符串转int数

分析:

经典题,主要需要注意输入中,允许先有空格,再来内容.

内容可能还不是整齐和规则的...

解法:

1.遍历空格

2.判断正负号

3.读数字

4.可能存在结尾号

代码:

https://github.com/LiLane/leetcode/blob/master/java/008-StringtoInteger(atoi)-201504292346.java

https://github.com/LiLane/leetcode/blob/master/c%2B%2B/008-StringtoInteger(atoi)-201504292346.cpp


[LeetCode]-007-String to Integer (atoi)

标签:

原文地址:http://blog.csdn.net/lane_l/article/details/45374693

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!