Homework/HW03/canfield.cc
void newShuffledPack(int *newDeck)
{
    int i, j;
    for (i=0; i<NUM_CARDS; i++)
        newDeck[i] = 1+i % NUM_RANKS; // add the cards in order
    for (i=0; i<NUM_CARDS-1; i++)     // then shuffle them
    {
        j = i+rand() % (NUM_CARDS-i); // random other card
        swap(newDeck[i], newDeck[j]); // swap them
    }
}
// Create a new pack of cards and shuffles them
Create a new pack of cards and shuffles them
Create a new pack of cards and shuffles them
void newShuffledPack(int *newDeck)
{
    int i, j;
    for (i=0; i<NUM_CARDS; i++)
        newDeck[i] = 1+i % NUM_RANKS; 
    for (i=0; i<NUM_CARDS-1; i++)     
    {
        j = i+rand() % (NUM_CARDS-i); 
        swap(newDeck[i], newDeck[j]); 
    }
}
void newShuffledPack ( int * newDeck ) { int i , j ; for ( i = 0 ; i < NUM_CARDS ; i ++ ) newDeck [ i ] = 1 + i % NUM_RANKS ; for ( i = 0 ; i < NUM_CARDS - 1 ; i ++ ) { j = i + rand ( ) % ( NUM_CARDS - i ) ; swap ( newDeck [ i ] , newDeck [ j ] ) ; } }
Create a new pack of cards and shuffles them
Create a new pack of cards and shuffles them
// add the cards in order // then shuffle them // random other card // swap them