Picking a random number from a list
#9

Quote:
Originally Posted by Pghpunkid
Посмотреть сообщение
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?
I think it was pretty hard for him. Wonder if he started sweating.
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: 4 Guest(s)