因此,如果在菜单中输入数字2或数字4,则基本上应该结束while循环。但是,循环不会结束,它会重新显示主菜单。如果我逐个单独使用这些语句就可以了,但是如果我将它们加入到一个条件中就会发生这种情况......
#include <stdio.h>
int main()
{
int answer;
int menunum;
answer = 0;
menunum = 0;
while(menunum !=4 || menunum != 2)
{
printf("Wellcome to my game in order to start pick the first option to set the number of questions you want to be asked \n");
printf("1. Enter the amount of questions you want to be asked \n");
printf("2. Start Quiz \n");
printf("3. Display the number of correct and incorrect answers \n");
printf("4. Exit the game \n");
scanf("%d", &menunum);
}
printf("END OF PROGRAM\n");
scanf("%d", &answer);
}
答案 0 :(得分:2)
所以基本上,如果数字2或数字4是,则while循环应该结束 在菜单中输入。
所以,用C语言写下你所说的话。
while(!(menunum == 4 || menunum == 2))
或(如果要包含<iso646.h>
)
while( not ( menunum == 4 or menunum == 2 ) )
相当于
while( menunum != 4 && menunum != 2 )