Blackjack: Simplified by removing rand_int function

This commit is contained in:
Logen Kain 2017-01-21 22:12:28 -07:00
parent 75e6fcea62
commit d511e6c4c2

View File

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