gpt4 book ai didi

c++ - while 循环不会在 C++ 中中断

转载 作者:行者123 更新时间:2023-11-28 00:53:32 25 4
gpt4 key购买 nike

<分区>

嘿,我正在用 C++ 制作游戏。这是大学作业,简要说明不使用头文件,游戏必须是基本的。问题是,游戏结束后仍然要求选择。我试图打破,退出,但仍然没有快乐。程序不会退出。谁能帮我解决这个问题?

这是我的代码:主要

int main()          //  The main function is set to int.  
// The return value has to be an integer value.
{
menuText();
while(menu) // Loop to revert back to menu when choice is not compatable with options.
{
int selection;
cout<< "Choice: ";
cin>> selection;

switch(selection)
{
case 1:
cout << "Start Game\n";
playGame();
break;
case 2:
cout << "Exit Game\n";
cout << "Please press enter to exit...\n";
menu = false ;
break;
}
}


system("pause"); // To stop the program from exiting prematurely.
return 0; // this is needed because the main is set to return
// an integer.
}

int playgame()
status Status = {100,20,80,80,20};// declaration of class members.
//Contents of PlayGame().............................
exitGame();
return 0;
}
void exitGame()
{
cout << "\n\nPlease press enter to exit the game.";
return;

}

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