Shuffle a deck of cards
Sigiloso
the algorithm is called knuth shuffle (i guess) it works like this. int card_idx; card_idx = 52 - 1; // (num_cards - 1) we have to index int deck_cards[52]; for(; card_idx > 0; card_idx--) { swap((rand() * num_cards) + 1, card_idx); // any swap algorithm should be good for this }