✔ 最佳答案
#include
#include
#include
using namespace std;
void display_card(int number);
int card_value(int number);
void display_player_cards(int* card_get, int card_num);
void replay_game(char &instruction);
void deal_card(int* card_get, int &ace, int &total, int current_card);
int main(int argc, char *argv[])
{
int card_get[5],card_num,total,ace,dealer,i;
char instruction;
srand(time(NULL));
replay:
ace=0;
total=0;
card_num=2;
for(i=0;i
>instruction;
system("cls");
if(instruction==89)
{
card_num++;
deal_card(card_get,ace,total,card_num-1);
display_player_cards(card_get,card_num);
check:
if(total<=21)
{
if(card_num==5)
{
cout<<"You Win!\n";
replay_game(instruction);
if(instruction==89)
{
goto replay;
}
}
else
{
goto hit;
}
}
else if(total-ace*10<=21)
{
ace--;
total-=10;
goto check;
}
else
{
cout<<"You Lose!\n";
replay_game(instruction);
if(instruction==89)
{
goto replay;
}
}
}
else
{
}
}
}
2008-03-27 00:01:06 補充:
Goto the following link to see the full code:
http://www.srcf.ucam.org/~cjc93/yahoo/bj.txt
2008-03-27 00:07:02 補充:
I did not use a "shuffle card" function, I only randomly generated cards out. So there might be cases where you get same cards appearing together.
2008-03-29 17:33:21 補充:
You need to input "Y" and "N" (Capital "Y" and Capital "N")
small letter "y" and small letter "n" will be treated as Capital "N"