大家好,我正在尝试制作一个输入-输出AI,我正在尝试输入的一些可能性,所以我尝试使用string.find()。但有时当我写句子时,它不起作用,可能是因为空格的原因。你能看一下告诉我出了什么问题吗?或者告诉我用什么来代替string.find?
std::string sentence;
std::cin >> sentence;
if (sentence.find("what") != std::string::npos)
{
if (sentence.find("are") != std::string::npos)
{
if (sentence.find("you") != std::string::npos)
{
if (sentence.find("?") != std::string::npos)
{
std::cout << "I am an AI" << std::endl;
}
}
}
}https://stackoverflow.com/questions/50749282
复制相似问题