Created
March 22, 2015 21:13
-
-
Save reportbase/b7aad2bcb495aea9262f to your computer and use it in GitHub Desktop.
random shuffle of array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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