Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 蒙蒂霍尔游戏:如何让用户选择门而不是程序自动随机选择?_C_Random_Printf_Scanf - Fatal编程技术网

C 蒙蒂霍尔游戏:如何让用户选择门而不是程序自动随机选择?

C 蒙蒂霍尔游戏:如何让用户选择门而不是程序自动随机选择?,c,random,printf,scanf,C,Random,Printf,Scanf,如果只有1、2或3是可接受的输入,则使用此选项: chosenDoor = rand() % 3 + 1; 这是正确的轨道吗?我知道此时,用户需要在程序“完成”之前输入10000次他的选择,那么有没有办法将第一个选择应用到其他9999试验 有没有办法将第一选择应用于其他9999试验 移动 printf("Choice:"); scanf("%d",&chosenDoor); 循环外的部分代码 printf("Choice:"); scanf("%d",&chosenDoor)

如果只有1、2或3是可接受的输入,则使用此选项:

chosenDoor = rand() % 3 + 1;
这是正确的轨道吗?我知道此时,用户需要在程序“完成”之前输入10000次他的选择,那么有没有办法将第一个选择应用到其他9999试验

有没有办法将第一选择应用于其他9999试验

移动

printf("Choice:");
scanf("%d",&chosenDoor);
循环外的部分代码

printf("Choice:");
scanf("%d",&chosenDoor);
printf("Choice: ");
scanf("%d", &chosenDoor);