Thread: deal or no deal coding

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    10

    deal or no deal coding

    Im trying to make a deal or no deal like game(for learning purposes) but after searching everywhere i can't find an answer to a huge problem. how do i create a random number generator that only generates specific numbers such as 1, 10, 100, 500... so on and so forth? also when i get an answer to that im realizing another problem. how will i be able to "tell" the other variables that certain numbers have already been taken and go to the next one(so to speak) so that the same number doesnt appear twice(or thrice).
    thanks in advance

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You could make a random number generator that would do that. Fortunately for all of us, that's not what you want to do. What you want to do is randomly shuffle those values around in your array of cases.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    10
    that was another thought i had but i didn't know if that was possible.

    ~edit
    is there anyway you can teach me how to do that?

  4. #4
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    I googled "C Shuffling Algorithms" and the first link that came up was some very simple C++ example code for shuffling an array of cards.

    The principle is exactly the same for what you want.

    C++ Notes: Example - Shuffle Array

    EDIT: The point of this post is, Google is your friend.
    Last edited by DeadPlanet; 04-18-2010 at 09:24 PM.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    43
    You could also use a vector with std::random_shuffle(), but that takes the fun out of things.

  6. #6
    Registered User
    Join Date
    Apr 2010
    Posts
    10
    thanks for all the help im going to start working on it now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal arrays
    By shel5210 in forum C Programming
    Replies: 2
    Last Post: 03-31-2010, 01:40 AM
  2. Deal or No Deal Proogram
    By shel5210 in forum C Programming
    Replies: 1
    Last Post: 03-28-2010, 08:04 PM
  3. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 06:53 PM
  4. Replies: 9
    Last Post: 03-20-2009, 05:22 PM
  5. pls fix my deal or no deal program
    By llinocoe in forum C Programming
    Replies: 5
    Last Post: 09-23-2008, 11:37 AM