Monty Hall problem: Difference between revisions
→{{header|C}}
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 676:
<syntaxhighlight lang="c">//Evidence of the Monty Hall solution.
#include <stdlib.h>
#include <stdio.h>
#include <
#include <time.h>
#include <math.h>
#define NumSim 10000000
unsigned long int i,stay=0;
int ChosenDoor,WinningDoor;
▲int main(void){
srand(time(NULL));
WinningDoor=rand() % 3; // choosing winning door.
ChosenDoor=rand() % 3; // selected door.
if(door[WinningDoor]=true,door[ChosenDoor])stay++;
door[WinningDoor]=false;
printf("\nAfter %u games, I won %u by switching. That is %f%%. ", GAMES, winsbyswitch, (float)winsbyswitch*100.0/(float)i);▼
}
▲ printf("\nAfter %
}
</syntaxhighlight>
Output of one run:
<pre> After
=={{header|C sharp|C#}}==
|