Thread: Random Pick

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2008
    Posts
    54
    Rep Power
    7

    Random Pick


    I am trying to write a short game program but cannot figure out how to start. Pseudocode would be fine. Not a completely programming.

    I have only these 5 combination patterns.
    OFF OFF OFF
    ON OFF ON
    ON ON OFF
    OFF ON ON
    ON ON ON

    I'd like to loop 5 time to randomly set the combination pattern and print out either exactly the combination set or different. The point is to trick the player to answer either "yes" or "no".

    Example:
    1.
    Set: ON OFF ON
    Print: ON OFF ON
    Answer: 'Y' or 'N'
    If the player answer 'Y' will be correct.

    2.
    Set: OFF ON ON
    Print: ON OFF ON
    Answer: 'Y' or 'N'
    Incorrect if the player answers 'Y'.

    Thanks in advance.

    -nodo
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,376
    Rep Power
    1871
    Is this really anything more than
    Code:
    char *s[] = {
    "OFF OFF OFF",
    "ON OFF ON",
    "ON ON OFF",
    "OFF ON ON",
    "ON ON ON"
    };
    Then picking two random numbers in range, printing out the associated string and getting an answer from the user?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo