Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<time.h>
- int main(int argc, char *argv[])
- {
- int tries = 0, correctstay = 0, correctmove = 0, car = 0, guess1 = 0, guess2 = 0, goat = 0, i, reveal;
- srand(time(NULL));
- for(tries = 0; tries < 10000;tries++)
- {
- car = rand()%3;
- guess1 = rand()%3;
- if(guess1 == car)
- {
- correctstay++;
- }
- for(i = 0;i < 3; i++)
- {
- if(i != car && i != guess1)
- {
- reveal = i;
- }
- }
- while(1)
- {
- guess2 = rand()%2;
- break;
- }
- guess2 = 3 - guess1 - reveal;
- if(guess2 == car)
- {
- correctmove++;
- }
- }
- printf("You played %d times\n", tries);
- printf("Won the car %d times without switching doors\n", correctstay);
- printf("Won the car %d times after switching doors\n", correctmove);
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement