Thread: RANDOM script
View Single Post
Old 2003-09-05, 07:07 PM   #2
bret
Shut up brain, or I'll stab you with a Q-tip!
 
bret's Avatar
 
Join Date: Aug 2003
Posts: 110
Simple. i will give it to you in c++ pseudo-code.

int[] thePictureArray = new int[200];
int[] theSelectedArray = new int[5];

/* fill thePictureArray with your pics, or if they are numberd 1 - 200 skip this step */

int select = 0;
int randomNumber = 0;
for( select = 0; select < 5; select++ )
{

boolean needNewNumber = true;

while( needNewNumber )
{
needNewNumber = false;
/* pick random number 0 - 200 */
randomNumber = random(0, 200);

/* check to see if it is used */
int check = 0;
for( check = 0; check <= select; check++ )
/* compare the number you picked with the numbers you have used */
if( randomNumber == theSelectedArray[check] )
needNewNumber = true;
}

theSelectedArray[select] = randomNumber; /* or thePictureArray[randomNumber];
}

that shoudl do it.
bret is offline   Reply With Quote