diff --git a/blackjack/blackjack.c b/blackjack/blackjack.c index 0b4c4cf..f8bdd2b 100644 --- a/blackjack/blackjack.c +++ b/blackjack/blackjack.c @@ -9,8 +9,6 @@ void print_deck (int *deckOfCards); void shuffel (int *array, int n); -static int rand_int(int n); - int main (int argc, char *argv[]) { int i; @@ -51,26 +49,11 @@ void shuffel (int *array, int n){ for (i=n; i>-1 ;i--){ - j = rand_int(i + 1); - - tmp = array[j]; - array[j] = array[i]; - array[i] = tmp; + if (i != 0){ + j = rand() % i; + tmp = array[j]; + array[j] = array[i]; + array[i] = tmp; + } } } - -static int rand_int(int n){ - - int limit = RAND_MAX - RAND_MAX % n; - - int rnd; - - do { - rnd=rand(); - } - while (rnd >= limit); - - return rnd % n; -} - -