我正在构建的程序在无限循环中运行,其中包含一个开关盒.我想在每种情况下插入一个while循环并在循环中执行一些操作,但是一旦给出键盘输入,循环就应该退出.因此,在从键盘获取输入之后,另一个案例在其中嵌套了while循环,并且该过程继续.
结构是:
while()//infinite loop
{
............... //operations
............... //operations
switch()
{
case 1:
............... //operations
............... //operations
while()//infinite loop
{
..............
..............
exit if there is any input from keyboard
}
break;
case 2:
............... //operations
............... //operations
while()//infinite loop
{
..............
..............
exit if there is any input from keyboard
}
break;
case n:
............... //operations
............... //operations
while()//infinite loop
{
..............
..............
exit if there is any input from keyboard
}
break;
}
}
Run Code Online (Sandbox Code Playgroud)
有什么办法吗???