Picking a random number from a list
#8

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
Quote:
Originally Posted by cessil
Посмотреть сообщение
store the numbers in an array.
count the numbers in the array.
generate random number from the total numbers in the array.
select the random number from the array index.
/sarcasm Thankyou for telling me exactly how to do it.
I got that 100%. I would have told you the same thing.


1. store the numbers in an array.
new rand[] = {3, 7, 25, 66, 9};

2. count the numbers in the array.
new size = sizeof(rand);

3. generate random number from the total numbers in the array.
new randn = random(size);

4. select the random number from the array index.
new random_value = rand[randn];

How hard is that?
Reply


Messages In This Thread
Picking a random number from a list - by Jack_Leslie - 13.07.2011, 05:36
Re: Picking a random number from a list - by cessil - 13.07.2011, 05:43
Re: Picking a random number from a list - by Jack_Leslie - 13.07.2011, 05:44
Re: Picking a random number from a list - by Backwardsman97 - 13.07.2011, 05:44
Re: Picking a random number from a list - by Jack_Leslie - 13.07.2011, 05:46
Re: Picking a random number from a list - by cessil - 13.07.2011, 05:50
Re: Picking a random number from a list - by Bakr - 13.07.2011, 05:53
Re: Picking a random number from a list - by Pghpunkid - 13.07.2011, 06:00
Re: Picking a random number from a list - by Steven82 - 13.07.2011, 06:16
Re: Picking a random number from a list - by PrawkC - 13.07.2011, 06:21

Forum Jump:


Users browsing this thread: 2 Guest(s)