View Single Post
Old 05-12-2005, 10:29 AM   #6 (permalink)
QUantumAnenome
Code Monkey
 
Join Date: Mar 2005
Posts: 56
QUantumAnenome is on a distinguished road
Send a message via Yahoo to QUantumAnenome
To randomize an array:

Code:
for (i=0; i<ARRAY_SIZE-1; i++)
{
     j = i + rand()%(ARRAY_SIZE-i);
     if (i != j)
          swap (array[i], array[j]);
}
The idea is this:

The first element gets a random card.
The second element gets a random card from the remaining 51
...
The last guy gets the last leftover card.

Last edited by redhead; 05-12-2005 at 12:32 PM. Reason: Deleted the unfinished post
QUantumAnenome is offline   Reply With Quote