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:)
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.
that was another thought i had but i didn't know if that was possible.
is there anyway you can teach me how to do that?
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.
You could also use a vector with std::random_shuffle(), but that takes the fun out of things.
thanks for all the help im going to start working on it now