写题时出现了bug,经过好多次的调试,才发现是stoi函数使用时没有注意一些事项。
int main()
{string s "";cout << stoi(s);return 0;
}类似上面的代码,s是个空字符串,或者s中不全是数字字符,就会出现…
int stoi( const std::string& str, std::size_t* pos 0, int base 10 ); 作用: 将 n 进制的字符串转化为十进制
用法: stoi(字符串,起始位置,n进制),将 n 进制的字符串转化为十进制
示…