gpt4 book ai didi

c++ - Case 语句不执行

转载 作者:行者123 更新时间:2023-11-30 01:20:56 25 4
gpt4 key购买 nike

这对我来说是一个越来越恼火的来源,当我按下案例的相应按钮(它们在上面初始化)时,它们实际上并没有执行,我被困在菜单中。

我敢肯定这非常简单,我只是没有看到。

编辑:根据要求添加更多内容

const int POKER = 1;
const int EVAL = 2;
const int EXIT = 3;
const char FIVE_CARD = 'a';
const char TEXAS = 'b';
const char OMAHA = 'c';
const char SEVEN_CARD = 'd';
const char GO_BACK = 'e';
const char MENU[] = "\nPlease choose an option from the following:\n"
"1) Play Poker\n2) Set Evaluation Method\n3) Quit\n: ";
const char POKER_MENU[] = "\nPlease choose your game:\n"
"a) 5 Card Draw\nb) Texas Hold 'Em\nc) Omaha High\n"
"d) 7 Card Stud\ne) Go back\n: ";
int main()
{
int choice = 0;
char poker_choice;

do
{
choice = askForInt(MENU, EXIT, POKER);
switch(choice)
{
case POKER :
do
{
choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
switch(poker_choice)
{
case FIVE_CARD :
std::cout << "Not implemented yet" << std::endl;
break;
case TEXAS :
std::cout << "Not implemented yet" << std::endl;
break;
case OMAHA :
std::cout << "Not implemented yet" << std::endl;
break;
case SEVEN_CARD :
std::cout << "Not implemented yet" << std::endl;
break;
case GO_BACK :
break;
}
}while(poker_choice != GO_BACK);
case EVAL :
std::cout << "Not implemented yet" << std::endl;
break;
case EXIT :
break;
}
}while(choice != EXIT);

最佳答案

choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);
应该是
poker_choice = askForChar(POKER_MENU, GO_BACK, FIVE_CARD);

关于c++ - Case 语句不执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18720695/

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