Arrays of random numbers
Arrays of random numbers
Out of context: Reply #4
- Started
- Last post
- 13 Responses
- ********0
First, how many elements in your array, and it can't be infinifty. What are the range of numbers? 0- 100, 0-20?
do a for loop for that ammount of elements.
Generate a random number with random() and check it's value against elements already existing in the array. Do that by getting the array length and having another for loop that checks, if it's not there, append it, if it's not, disregard it.
There you go, should slow down if you want like 1000, but should be reasonably quick for modest amount.