“常用公式”在线计算,“设计手册”在线查询
(ThisfunctioniscalledAtoI(oratoi())becauseweareconvertinganASCIIstringintoaninteger.)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 支持支持 反对反对

共 1 个关于本帖的回复 最后回复于 2013-7-30 13:57

沙发
宋倩倩 新来的 发表于 2013-7-30 13:57:17 | 只看该作者
研发埠培训中心
Good answer:Go through the string from beginning to end.If the first character is a negative sign,remember this fact.Keep a running total,which starts at 0.Each time your each a new digit,multiply the total by 10 and add the new digit.When you reach the end,return the current total,or,if there was a negative sign,the inverse of the number.Okay answer:Another approach is to go through the string from end to beginning,again keeping a running total.Also,remember a number x representing which digityou are currently on;x is initially 1.For each character,add the current digit times x to the running total,and multiply x by 10.When you reach the beginning,return the current total,or,if there was a negative sign,the inverse of the number.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注我们

360网站安全检测平台