/* Name: Blackjack Copyright: 2005 Becky Talbot All Rights Reserved Source code may be duplicated and redistributed for educational purposes only and provided this copyright notice is kept intact. Author: Becky Talbot Date: 08/05/05 18:20 Description: A game of blackjack. one player(user), one dealer(computer) */ #include #include #include using namespace std; const int HIGH=11; const int LOW=1; int card; void cards(int); int main(int argc, char *argv[]) { int pile; int dpile; int dcard; char end = 121; int game=1; char i; char choice; time_t(seconds); time(&seconds); srand((unsigned int)seconds); while(choice!='4') //Start all { cout<<"|*********Blackjack*********|"<>choice; pile=0; //reset piles dpile=0; end=121; //reset game status game=1; if(choice=='2') //instruction menu { cout<<"|***************************Rules***************************|"<>i; } else if(choice=='3') //information menu { cout<<"*********Information**********"<>i; } else if(choice=='1') //game start { while((end!=88) && (end!=120) && (pile<21)) //start deal { for(int b=1; b<10000000;b++) {} cout << "**********Blackjack_"<>card; }while((card!=1)&&(card!=11)); } else if(card==11) //player royals { card=10; } cout<<"Card1: " <>card; }while((card!=1)&&(card!=11)); } else if(card==11) //card2 royals card=10; pile = pile+card; //add card2 to pile cout<<"Card2: " <1) //start other games { card = rand()%(HIGH-LOW+1)+LOW; cards(card); if(card==1) //card aces { do { cout<<"You have an Ace. Your total is currently "<>card; }while((card!=1)&&(card!=11)); } else if(card==11) //card royals card=10; pile = pile+card; //add card to pile cout<<"You were dealt " << card << " points." << endl; cout<<"Your pile has a total of " << pile << " points." << endl; cout<>end; } else cout<<"You bust"<21) cout<<"Dealer busts."<dpile)) cout<<"You beat the dealer."<21) cout<<"You bust, dealer wins."; else if((pile!=21)&&(dpile==21)) cout<<"Dealer gets blackjack. Dealer wins."; else if((dpile>21)&&(pile<21)) cout<<"You win."<