/*---------------------------------------------------------- Elizabeth Sklar Assignment #6 MC140.0X 20 October 2000 This program simluates dealing and sorting four hands of hearts (13 cards/hand). Then the program determines which player is holding the queen of spades. A deck of cards is defined as a 52-element array, as follows: 0 1 2 3 4 5 6 7 8 9 10 11 12 clubs: 2 3 4 5 6 7 8 9 10 J Q K A 13 14 15 16 17 18 19 20 21 22 23 24 25 diamonds: 2 3 4 5 6 7 8 9 10 J Q K A 26 27 28 29 30 31 32 33 34 35 36 37 38 hearts: 2 3 4 5 6 7 8 9 10 J Q K A 39 40 41 42 43 44 45 46 47 48 49 50 51 spades: 2 3 4 5 6 7 8 9 10 J Q K A ----------------------------------------------------------*/ #include #include #include #include #define TRUE 1 #define FALSE 0 int deck[52]; int player1[13]; int player2[13]; int player3[13]; int player4[13]; /*--------------------------------------------------------*/ /* quit */ /* */ /* This function prints a message when before the program */ /* exits. */ /* */ /*--------------------------------------------------------*/ void quit() { printf( "Thanks for playing!\n" ); } /* end of quit() */ /*--------------------------------------------------------*/ /* shuffle */ /* */ /* This function virtually shuffles the deck, by setting */ /* all the "dealt" flags in the deck to FALSE. */ /* */ /*--------------------------------------------------------*/ void shuffle() { // you have to write this code } /* end of shuffle() */ /*--------------------------------------------------------*/ /* deal_one_card */ /* */ /* This function deals one card, by randomly picking a */ /* card that hasn't been dealt yet and then setting that */ /* card's "dealt" flag to TRUE. */ /* */ /*--------------------------------------------------------*/ int deal_one_card() { // you have to write this code } /* end of deal_one_card() */ /*--------------------------------------------------------*/ /* deal */ /* */ /* This function deals 13 cards to each player. */ /* */ /*--------------------------------------------------------*/ void deal() { // you have to write this code } /* end of deal() */ /*--------------------------------------------------------*/ /* find_rank */ /* */ /* this function returns a single character indicating */ /* the rank of the i-th card in the deck. */ /* */ /* return value: */ /* 2..9 = 2..9 */ /* 0 = 10 */ /* J = jack */ /* Q = queen */ /* K = king */ /* A = ace */ /* */ /*--------------------------------------------------------*/ char find_rank( int i ) { // you have to write this code } /* end of find_rank() */ /*--------------------------------------------------------*/ /* find_suit */ /* */ /* this function returns a single character indicating */ /* the suit of the i-th card in the deck. */ /* */ /* return value: */ /* C = clubs */ /* D = diamonds */ /* H = hearts */ /* S = spades */ /* */ /*--------------------------------------------------------*/ char find_suit( int i ) { // you have to write this code } /* end of find_suit() */ /*--------------------------------------------------------*/ /* deal */ /* */ /* This function deals 5 cards to each player. */ /* */ /*--------------------------------------------------------*/ void print_card( int i ) { // you have to write this code } /* end of print_card() */ /*--------------------------------------------------------*/ /* print_hands */ /* */ /* This function prints the contents of all the hands. */ /* */ /*--------------------------------------------------------*/ void print_hands() { // you have to write this code } /* end of print_hands() */ /*--------------------------------------------------------*/ /* swap */ /* */ /* This function swaps the values in the two integer */ /* arguments. */ /* */ /*--------------------------------------------------------*/ void swap( int *a, int *b ) { // you have to write this code } /* end of swap() */ /*--------------------------------------------------------*/ /* sort_hand */ /* */ /* This function sorts the entries in the "hand" argument,*/ /* in ascending order, using bubble sort. */ /* */ /*--------------------------------------------------------*/ void sort_hand( int hand[] ) { // you have to write this code } /* end of sort_hand() */ /*--------------------------------------------------------*/ /* search_hand */ /* */ /* This function searches for the "key" argument in the */ /* "hand" argument, using binary search and recursion. */ /* */ /*--------------------------------------------------------*/ int search_hand( int hand[],int key,int lo,int hi ) { // you have to write this code } /* end of search_hand() */ /*--------------------------------------------------------*/ /* main program */ /* */ /*--------------------------------------------------------*/ void main() { time_t *t = NULL; srand( (unsigned int)time( t ) ); shuffle(); deal(); printf( "here are the hands in unsorted order:\n" ); print_hands(); printf( "\n" ); // you have to write code to sort each player's hand, // in ascending order, and then print all the hands // in sorted order ... printf( "here are the hands in sorted order:\n" ); print_hands(); printf( "\n" ); // you have to write code to search each player's hand // for the queen of spades, and then print out which // player has that evil card ... quit(); } /* end of main() */