Monty Hall problem: Difference between revisions
→{{header|XPL0}}: The procedure Play replaced by a pure function.
(→{{header|XPL0}}: The procedure Play replaced by a pure function.) |
|||
Line 5,161:
=={{header|XPL0}}==
<syntaxhighlight lang="xpl0">def
int Game,
include c:\cxpl\codes;
int Switch;
int Car, Player, Player0, Monty;
Line 5,176:
until Player # Player0 and Player # Monty
else Player:= Player0; \player sticks with original door
];
[Format(2,1);
Text(0, "
for Game:= 0 to
if IsGameWon(false) then NWins:= NWins+1;
RlOut(0, float(
Text(0, "% of games.^M^J");
Text(0, "But switching doors wins car in ");
for Game:= 0 to
if IsGameWon(true) then NWins:= NWins+1;
RlOut(0, float(
Text(0, "% of games.^M^J");
]</syntaxhighlight>
Line 5,195 ⟶ 5,197:
Example output:
<pre>
But switching doors wins car in 66.7% of games.
</pre>
=={{header|Yabasic}}==
|