problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing87::Solution类 参考

#include <acwing.h>

静态 Public 成员函数

static int strToInt (string str)
 

详细描述

在文件 acwing.h1543 行定义.

成员函数说明

◆ strToInt()

int acwing::acwing87::Solution::strToInt ( string  str)
static

在文件 acwing.cpp4897 行定义.

4897 {
4898 for(int i = 0; i < str.length(); i++) {
4899 if(str[i] != ' ') {
4900 str = str.substr(i);
4901 break;
4902 }
4903 }
4904 bool pos = true;
4905 if(str[0] == '+' || str[0] == '-') {
4906 pos = str[0] == '+';
4907 str = str.substr(1);
4908 }
4909 unsigned long long ans = 0;
4910 for(const char ch: str) {
4911 if(isdigit(ch) != 0) {
4912 ans *= 10;
4913 ans += ch - '0';
4914 } else {
4915 break;
4916 }
4917 }
4918 return ans > INT_MAX
4919 ? (pos ? INT_MAX : INT_MIN)
4920 : pos
4921 ? ans
4922 : -ans;
4923 }

被这些函数引用 acwing::acwing87::TEST().


该类的文档由以下文件生成: