Random numbers with no repeat
Author |
Message |
bmass
|
Posted: Sun Dec 10, 2006 4:10 pm Post subject: Random numbers with no repeat |
|
|
Hey there, I need to randomly generate 16 numbers from 0 - 15, but they must all be different. Essentially I need to generate the numbers from 0 - 15 in a random order. I also need to do it multiple times. If anyone could help me with this it would be greatly appreciated. Thanks. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sun Dec 10, 2006 4:15 pm Post subject: (No subject) |
|
|
use an array to keep the numbers not yet picked, then randomly pick a position in the array and take that number out. Repeat until your array size is 0. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
|
|