atoi 自己实现 leecode
来源:互联网 发布:搬瓦工 centos 7 和 6 编辑:程序博客网 时间:2024/05/20 08:23
//测试数据 0k4 2147483648 -1 1 " 10522545459"#include <stdio.h>#include <string.h>#include <stdlib.h>#include <ctype.h>#include <limits.h>class Solution {public: int atoi(const char *str) { long long total = 0; while (isspace(*str)) str++; int c = (int)(unsigned char)*str++; int sign = 1; if (c == '-' || c == '+'){ sign = c; c = (int)(unsigned char)*str++; } while (c == '0'){ c = (int)(unsigned char)*str++; } if (!isdigit(c)) return total; while (isdigit(c)){ total = total*10 + (c - '0'); c = (int)(unsigned char)*str++; } if (sign == '-') return (-total < INT_MIN) ? INT_MIN : -total; return (total > INT_MAX) ? INT_MAX : total; }};int main(){ char *a = " 10522545459"; Solution d; int c = d.atoi(a); printf("%d",c); return 0;}
0 0
- atoi 自己实现 leecode
- 自己实现atoi系列
- 自己实现atoi系列
- 自己实现atoi函数
- 自己实现atoi函数
- 自己实现atoi
- 自己实现atoi系列(atoi函数)
- 自己实现atoi和atof
- 自己实现的atoi函数
- LeeCode-String to Integer (atoi)
- LeeCode String to Integer (atoi)
- atoi 函数自己写代码实现
- 自己实现的atof()和atoi()代码
- LeetCode(atoi)实现atoi
- 字符串string转整数int 实现自己的atoi函数
- 自己编写代码实现atoi和itoa函数的功能
- 自己编写代码实现atoi和itoa函数的功能
- atoi实现
- 复色光如果她
- 【服务器架构】10万在线的WebGame的架构设计思路
- 就会嘎的
- Java web 负载均衡 和 缓存
- 最大公约数和最小公倍数
- atoi 自己实现 leecode
- sgdfh
- js 正则表达式 判断是否是纯数字
- HibernateUtil工具 高级本地线程的Session封装 高级增删查改及分页实现
- 如何更改在local server本地服务器运行的Wordpress的密码PS
- 第一章例题2突击战UVa11729(贪心)
- healthKit的一些知识点
- HDU 2504 又见GCD
- 呜呜呜呜呜呜呜呜呜呜呜呜呜