diff --git a/blackjack/blackjack.c b/blackjack/blackjack.c index 29a97aa..2063fc2 100644 --- a/blackjack/blackjack.c +++ b/blackjack/blackjack.c @@ -7,7 +7,7 @@ #define len(x) sizeof(x)/sizeof(x[0]) void print_deck (int *deckOfCards); -void shuffel (int *array, int n); +void shuffel (int *array); int main (int argc, char *argv[]) { @@ -26,7 +26,7 @@ int main (int argc, char *argv[]) deckOfCards[i]=i; } - shuffel(deckOfCards, CARD_MAX); + shuffel(deckOfCards); print_deck(deckOfCards); @@ -42,16 +42,19 @@ void print_deck(int *deckOfCards){ } } -void shuffel (int *array, int n){ +void shuffel (int *array){ - int i, j, tmp; + int i, rn, a , tmp; - for (i=n; i >= len(array) ;i--){ + rn = rand(); + printf("%d\n", rn); + + for (i=CARD_MAX; i >= CARD_MAX/CARD_MAX ;i--){ if (i != 0){ - j = rand() % i; - tmp = array[j]; - array[j] = array[i]; + a = rn % i; + tmp = array[a]; + array[a] = array[i]; array[i] = tmp; } }