Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualEctara

Posted 21 May 2013 - 10:07 PM

use not Num_Array.push_back(i); but something like Num_Array.push_back(rand());

This fails the requirement, because it's possible that rand() will return the same number at least twice in the nine calls.

The only true way to do it is to shuffle the possible values, like shuffling a deck of cards, rather than randomly picking a card from a huge pile and hoping there are no duplicates.

I am doing what you suggested .






Posted Today, 04:35 PM


What's the question?

how do I generate 9 random numbers that do not repeat?
It looks like you did. Try telling us what you expected to happen, and what actually happened, and be as specific as possible.

#3Ectara

Posted 21 May 2013 - 08:19 PM

use not Num_Array.push_back(i); but something like Num_Array.push_back(rand());

This fails the requirement, because it's possible that rand() will return the same number at least once in the nine calls.

The only true way to do it is to shuffle the possible values, like shuffling a deck of cards, rather than randomly picking a card from a huge pile and hoping there are no duplicates.

I am doing what you suggested .





Posted Today, 04:35 PM


What's the question?

how do I generate 9 random numbers that do not repeat?
It looks like you did. Try telling us what you expected to happen, and what actually happened, and be as specific as possible.

#2Ectara

Posted 21 May 2013 - 08:19 PM

use not Num_Array.push_back(i); but something like Num_Array.push_back(rand());

This fails the requirement, because it's possible that rand() will return the same number at least once in the nine calls.

The only true way to do it is to shuffle the possible values, like shuffling a deck of cards, rather than randomly picking a card from a huge pile and hoping there are no duplicates.

I am doing what you suggested .





Posted Today, 04:35 PM


What's the question?

how do I generate 9 random numbers that do not repeat?
It looks like you did. Try telling us what you expected to happen, and what actually happened, and be as specific as possible.

#1Ectara

Posted 21 May 2013 - 08:17 PM

use not Num_Array.push_back(i); but something like Num_Array.push_back(rand());

This fails the requirement, because it's possible that rand() will return the same number at least once in the nine calls.

 

The only true way to do it is to shuffle the possible values, like shuffling a deck of cards, rather than randomly picking a card from a huge pile and hoping there are no duplicates.


PARTNERS