type
status
date
slug
summary
tags
category
icon
password
📝 LCR 192. 不使用库函数的字符串转整数
题目描述
题解
我认为还是一个自动机,不过相对来说重点不是自动机,而是检查数字越界
🤗 总结归纳
根据题意,有以下四种字符需要考虑:
首部空格: 删除之即可;
符号位: 三种情况,即 ''+++'' , ''−-−'' , ''无符号" ;新建一个变量保存符号位,返回前判断正负即
数字越界处理:因此需要考虑数字越界问题。而由于题目指出 环境只能存储 32 位大小的有符号整数 ,因此判断数字越界时,要始终保持 resresres 在 int 类型的取值范围内。
- Author:KIRITO
- URL:https://kirito.work/article/01278902-b0e1-4e62-a7ad-76331f749407
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!