在 C++ 中,您将如何编写递归检查给定输入是否为有效浮点值的程序。
最佳答案
问题出在这一行:
nextChar= strExp.at(first + 1);
因为如果字符串的大小为 1,它将变为 strExp(1)
char nextChar=' ';
if(first+1<length)
nextChar= strExp.at(first + 1);
而且最好通过引用而不是值来传递字符串
int endInt(const string& strExp, int first)
{
//...
}
关于c++ - 递归检查数字的有效性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21944512/