36 lines
1.0 KiB
Plaintext
36 lines
1.0 KiB
Plaintext
' version 19-01-2019
|
|
' compile with: fbc -s console
|
|
|
|
Const As Integer max = 1000000
|
|
Randomize Timer
|
|
|
|
Dim As UInteger i, car_door, chosen_door, montys_door, stay, switch
|
|
|
|
For i = 1 To max
|
|
car_door = Fix(Rnd * 3) + 1
|
|
chosen_door = Fix(Rnd * 3) + 1
|
|
If car_door <> chosen_door Then
|
|
montys_door = 6 - car_door - chosen_door
|
|
Else
|
|
Do
|
|
montys_door = Fix(Rnd * 3) + 1
|
|
Loop Until montys_door <> car_door
|
|
End If
|
|
'Print car_door,chosen_door,montys_door
|
|
' stay
|
|
If car_door = chosen_door Then stay += 1
|
|
' switch
|
|
If car_door = 6 - montys_door - chosen_door Then switch +=1
|
|
Next
|
|
|
|
Print Using "If you stick to your choice, you have a ##.## percent" _
|
|
+ " chance to win"; stay / max * 100
|
|
Print Using "If you switched, you have a ##.## percent chance to win"; _
|
|
switch / max * 100
|
|
|
|
' empty keyboard buffer
|
|
While InKey <> "" : Wend
|
|
Print : Print "hit any key to end program"
|
|
Sleep
|
|
End
|