#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define Bet 100;
int main(){
int Player1,Player2,Player3;
int Com1,Com2,Com3;
int Player,Com;
int Money=1000;
int Count1,Count2,Count3;
int Count4,Count5;
int Select;
char ch;
int Betting;
char Card;
srand(time(NULL));
rand();rand();rand();
srand(rand());
Count1 = Count2 = Count3 = 0;
Count4 = Count5 = 0;
while(1){
system("cls");
printf(" ==== 블랙잭 ====\n");
printf(" 1. 게임시작 \n");
printf(" 2. 점수\n");
printf(" 3. 게임 끝\n");
printf(" > ");
scanf("%d",&Select);
system("cls");
switch(Select){
case 1:
Money = Money - Bet;
Betting = 0;
Player1 = rand()%13+1;
Player2 = rand()%13+1;
printf("=================\n");
printf("|| %d ||\n",Player1);
printf("=================\n");
printf("=================\n");
printf("|| %d ||\n",Player2);
printf("=================\n");
printf("당신의 카드의 합 : %d\n",Player1+Player2);
printf("\n");
Com1 = rand()%13+1;
Com2 = rand()%13+1;
printf("=================\n");
printf("|| %d ||\n",Com1);
printf("=================\n");
printf("=================\n");
printf("|| %d ||\n",Com2);
printf("=================\n");
printf("컴퓨터의 카드의 합 : %d\n",Com1+Com2);
while(1){
printf("카드를 하나 더 받겠습니까? (y/n) :");
fflush(stdin);
scanf("%c",&Card);
if(Card=='Y' || Card == 'y'){
Player3 = rand()%13+1;
printf("=================\n");
printf("|| %d ||\n",Player3);
printf("=================\n");
Count4++;
}else if(Card=='N' || Card == 'n'){
Player3 = 0;
break;
}else{
printf("잘못 입력하셨습니다 \n");
system("pause");
}
Player = Player1+Player2+Player3;
printf("\n");
printf("당신 카드의 총합 : %d \n",Player);
}
system("pause");
while(1){
if((Com1+Com2)<16){
printf("\n");
printf("컴퓨터가 카드를 한장 더 받았습니다.\n");
printf("\n");
Com3 = rand()%13+1;
Count5++;
}else if(16 <= (Com1+Com2) && (Com1+Com2) <=21){
Com3 = 0;
break;
}
}
Com = Com1+Com2+Com3;
printf("배팅을 하시겠습니까? (y/n) : ");
fflush(stdin);
scanf("%c",&ch);
if(ch=='Y' || ch == 'y'){
printf("배팅금액 설정 ( 0 ~ %d ) : ",Money);
scanf("%d",&Betting);
}
printf("컴퓨터의 카드의 합 : %d\n",Com);
switch(ch){
case 'y': //배팅을 걸때 상황
if((Player<=21||Com<Player)||Count4<Count5){
printf("당신이 이겼습니다.\n");
Money = Money + (Betting*2) + Bet;
Count1++;
}else if((Player>21&&Com>Player)||Count4>Count5){
printf("당신이 졌습니다.\n");
Money = Money - Betting;
Count2++;
}else{
printf("비겼습니다.\n");
Money = Money + Bet;
Count3++;
}break;
case 'n': //배팅을 안걸때 상황
if((Player<=21||Com<Player)||Count4<Count5){
printf("당신이 이겼습니다.\n");
Money = Money + Bet;
Count1++;
}else if((Player>21&&Com>Player)||Count4>Count5){
printf("당신이 졌습니다.\n");
Count2++;
}else{
printf("비겼습니다.\n");
Money = Money + Bet;
Count3++;
}break;
}
break;
case 2: //스코어
printf("<< 당신의 전적 >>\n");
printf(" W I N : %d\n",Count1);
printf(" L O S E : %d\n",Count2);
printf(" D R A W : %d\n",Count3);
printf("보유하고 있는 금액 : %d\n",Money);
break;
case 3:
return 0;
default :
printf("잘못 누르셨습니다 1~3중만 고르세요\n");
}
system("pause");
}
}
미완성본 에러가 계속 나는데 왜 그런지 모르겠다 ㅜㅜ