Skip to content

Instantly share code, notes, and snippets.

@reportbase
Created March 22, 2015 21:13
Show Gist options
  • Save reportbase/b7aad2bcb495aea9262f to your computer and use it in GitHub Desktop.
Save reportbase/b7aad2bcb495aea9262f to your computer and use it in GitHub Desktop.
random shuffle of array
inline void shuffle(int* card, int cardsn)
{
for(int n = 0; n < cardsn; n++)
{
int adj = cardsn - n;
int m = (rand() % adj) + n;
int tmp = card[n];
card[n] = card[m];
card[m] = tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment