Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<time.h>
  4.  
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. int tries = 0, correctstay = 0, correctmove = 0, car = 0, guess1 = 0, guess2 = 0, goat = 0, i, reveal;
  9. srand(time(NULL));
  10.  
  11. for(tries = 0; tries < 10000;tries++)
  12. {
  13. car = rand()%3;
  14. guess1 = rand()%3;
  15. if(guess1 == car)
  16. {
  17. correctstay++;
  18. }
  19. for(i = 0;i < 3; i++)
  20. {
  21. if(i != car && i != guess1)
  22. {
  23. reveal = i;
  24. }
  25. }
  26.  
  27. while(1)
  28. {
  29. guess2 = rand()%2;
  30. break;
  31. }
  32. guess2 = 3 - guess1 - reveal;
  33.  
  34. if(guess2 == car)
  35. {
  36. correctmove++;
  37. }
  38. }
  39. printf("You played %d times\n", tries);
  40. printf("Won the car %d times without switching doors\n", correctstay);
  41. printf("Won the car %d times after switching doors\n", correctmove);
  42.  
  43. getchar();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement