gpt4 book ai didi

C++ if/else语句问题

转载 作者:太空宇宙 更新时间:2023-11-04 14:35:32 27 4
gpt4 key购买 nike

<分区>

前几天我在使用 xcode,并且正在开发一个基于文本的对话游戏。

#include <iostream>

int main()
{
std::cout<<"Conversation simulator requires you to type in all caps for all of your replies"<<std::endl;
std::cout<<"Type your first and last name!"<<std::endl;
std::string fname = " ";
std::string lname = " ";
bool samename = false;
std::cin>> fname >> lname ;
if (fname == "MUSCLE" and lname == "MAN")
std::cout<< "Wow, we have the same first and last name!"<<std::endl;
samename = true;
else
std::cout<< fname << " "<< lname << "is a very nice name"<<std::endl;

return 0;
}

对我来说似乎没什么问题,但 Xcode 不会运行,因为在这一行:

else

它期待一个表达式?我想不出这意味着什么。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com