need help! (c/c++ lets make a deal/monty hall problem)

Discussion in 'C++' started by Marson, Feb 15, 2010.

  1. Marson

    Marson New Member

    Joined:
    Feb 15, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi, I am fairly new to c programming and am currently having problems with the "monty hall problem." I will type it up a few lines down. Basically I do not know where to start and was hoping you guys would have some ideas for me. Maybe outlining how the function should operate if that is possible. Anyways, here is the problem, and any help is really appreciated. Thanks!

    There are 3 doors, behind 1 door is a prize and behind the other 2 are goats (not prizes). The player selects one of the doors. The host knows what is behind each door. The host opens another door not selected by the player. If the player selects a door with a goat behind it, the host has to open the door with the other goat. If the prize is selected by the player, the host can pick either door. Now the player makes a choice, either to stay with his/her door or to switch to the remaining closed door. I am supposed to write a program to simulate the game, and run it 10,000 iterations, 100,000 iterations, and 1,000,000 iterations, always keeping track of the number of wins/losses. It should turn out about 60% of the time the player wins by switching doors.




    Matt
     
  2. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    declare an array to have 3 elements (int doors[3];)
    each one will represent a door

    fill the above array randomly(use srand,rand ) with the numbers 1,2,3
    1=goat
    2=price
    3=goat

    do this first ,post your code and i will help you.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice