Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- int iterations = 100000;
- int win = 0;
- int lose = 0;
- int openedDoor = 0;
- void main()
- {
- srand(time(0));
- int winDoor[3];
- int choose = 0;
- for (int i = 0; i < iterations; i++)
- {
- for (int i = 0; i < 3; i++)
- {
- winDoor[i] = 0;
- }
- winDoor[rand() % 3] = 1;
- choose = rand() % 3;
- while (1)
- {
- int j = rand() % 3;
- if ((winDoor[j] != 1)&&(j!=choose))
- {
- openedDoor = j;
- break;
- }
- }
- if (winDoor[choose] == 1)
- {
- win++;
- }
- else
- {
- lose++;
- }
- }
- printf_s("%d\n", win);
- printf_s("%d\n", lose);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement