入力が有効でない場合はメニューを作成する必要があります。それは有効な入力を求め続ける必要があります。私は(Cで)以下複数の条件のテスト(C言語)
#include <stdio.h>
int main()
{
int input = 0;
printf("What would you like to do? \n 1 (Subtraction) \n 2 (Comparison) \n 3 (Odd/Even) \n 4 (Exit) \n ");
scanf_s("%d", &input);
while (input != 1 || input != 2 || input != 3|| input != 4)
{
printf("Please enter a valid option \n");
scanf_s("%d", &input);
} // At this point, I think it should keep testing variable input and if it's not either 1 or 2 or 3 or 4. It would keep looping.
しかし、何が起こっているのである、それは例えば、入力された場合でもループ、2
すべての入力がどちらか1から、または異なっているので、あなたの中の状態は常に 'true'をあります2. '&|'で '||'を変更する必要があります。 – Franck
入力が1 *と* 2 *、* 3 *と* 4(同時に)の場合、ループは停止します。これは不可能です。だから永遠にループします。 – alk
@Franckしかし、私が2を入力した場合、条件がこの場合真ではないのですか? – Ansh