random fill generator

Thread Starter

stevy123

Joined Nov 19, 2007
61
Hi All

Just wondering could anyone help me with a little code i am trying to write.

I have 6 numbers i.e 100, 200, 300, 300, 500, 600 and want to randomly allocate them into 6 set locations. I am usign c++ so is there any easy way of doing this?

Then how do i check to see which number is stored were?

Many thanks
Steve
 

Thread Starter

stevy123

Joined Nov 19, 2007
61
Hi beenthere thanks for your response, but as i have said in the question i dotn want it just to be random numbers i want it to b 1 of the 6 selected numbers to be randomly assigned into 1 of the 6 locations.

Anyone any ideas?

Regards
Steve
 

veritas

Joined Feb 7, 2008
167
Just use a random number generator function, like one that produces a value from 0 to 1, and then use logic to partition the results into your 6 bins. e.g. 0-0.166 => 100, 0.167-0.333 => 200, etc.

If the random number has already been assigned, generate a different one.
 

Art

Joined Sep 10, 2007
806
Put the 6 values into a 6 value wide array,
use the random number from 0-5 to generate a pointer to the array.
 
Top