Why is this so

Pages: 12
@ButchCavendish what do you exactly mean ? Post your random number code here.
I've another question, I've printed random numbers using rand(); But my problem is that if a number is printed, it should not be printed again.. How can I do that ?

Perhaps this question deserves a separate thread, as it's a separate topic. But still, you need some way of keeping track of which numbers have already been used. For example you could store the random number in a std::vector or perhaps a std::set, and before printing each newly-generated number, check whether it is already stored. If it's there, try again, if not store and print the number.

Depending on the context there might be other solutions. for example if you want to choose a random playing card, but make sure it is different each time.
I've not coded it yet, I'm trying this in shuffling the Deck of Cards
Topic archived. No new replies allowed.
Pages: 12