Blackjack: removed redundant 'CARD_MAX' from shuffel function

This commit is contained in:
Logen Kain 2017-01-21 23:12:08 -07:00
parent 74f02e4537
commit c281be6ce8

View File

@ -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;
}
}