|
|
@ -11,7 +11,6 @@ int blackjack(){ |
|
|
|
|
|
|
|
int balance = getBalanceBJ(); |
|
|
|
|
|
|
|
printf("rand card: %d\n", getRandCard()); |
|
|
|
|
|
|
|
while(balance > 0){ |
|
|
|
int bet = getBetBJ(balance); |
|
|
@ -57,11 +56,10 @@ int userInputBJ(){ |
|
|
|
// 1 = Ass |
|
|
|
int getRandCard(){ |
|
|
|
|
|
|
|
srand(time(NULL)); |
|
|
|
|
|
|
|
int r = rand() % 13; |
|
|
|
r++; |
|
|
|
|
|
|
|
|
|
|
|
if(r > 10){ |
|
|
|
return 10; |
|
|
|
} |
|
|
@ -71,6 +69,7 @@ int getRandCard(){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int playBJ(int bet, int balance){ |
|
|
|
|
|
|
|
int *computerCardArray = (int*) malloc(10 * sizeof(int)); |
|
|
@ -79,6 +78,19 @@ int playBJ(int bet, int balance){ |
|
|
|
computerCardArray[0] = getRandCard(); |
|
|
|
printf("computer rand card: %d\n", computerCardArray[0]); |
|
|
|
|
|
|
|
int *userCardArray = (int*) malloc(10 * sizeof(int)); |
|
|
|
|
|
|
|
if(userCardArray){ |
|
|
|
|
|
|
|
userCardArray[0] = getRandCard(); |
|
|
|
printf("user rand card: %d\n", userCardArray[0]); |
|
|
|
userCardArray[1] = getRandCard(); |
|
|
|
printf("user rand card: %d\n", userCardArray[1]); |
|
|
|
|
|
|
|
|
|
|
|
free(userCardArray); |
|
|
|
} |
|
|
|
|
|
|
|
free(computerCardArray); |
|
|
|
} |
|
|
|
|
|
|
|