Question: ONLY C PROGRAMMING... I PROVIDE YOU CODE HERE AND FUNCTIONS THAT YOU NEED TO CODE IS ON JPEG FILE ALSO AN OUTPUT. #include #include #include

ONLY C PROGRAMMING... I PROVIDE YOU CODE HERE AND FUNCTIONS THAT YOU NEED TO CODE IS ON JPEG FILE ALSO AN OUTPUT.
#include
#include
#include
#define SUITS 4
#define FACES 13
#define CARDS 52
#define HAND_SIZE 5
#define HANDS_IN_DECK 10
#define NUMBER_OF_HANDS_PLAYED 10000000//Currently set to 10 million
#define NUMB_HANDS_STR "10 million" //Currently set to 10 million
#define TRUE 1
#define FALSE 0
// prototypes of functions supplied
void deal(const unsigned int wDeck[], const char* wFace[],//display all cards in deck
const char* wSuit[]);
void dealNextHand(unsigned int wDeck[], unsigned int hand[]); //deal out next hand from the deck
int isFourOfAKind(const unsigned int hand[]); // return true if hand contains four of a kind and false otherwise
// prototypes of functions you must implement
void swap(unsigned int* const, unsigned int* const); //swap the two cards pointed to by the 2 pointers
void shuffle(unsigned int wDeck[]); //shuffle deck
int isPair(const unsigned int hand[]); // return true if hand contains a pair and false otherwise
int isTwoPair(const unsigned int hand[]); // return true if hand contains a two pair and false otherwise
int isThreeOfAKind(const unsigned int hand[]); // return true if hand contains three of a kind and false otherwise
int isStraight(const unsigned int hand[]); // return true if hand is a straight and false otherwise
int isFlush(const unsigned int hand[]); // return true if hand is a flush and false otherwise
int isFullHouse(const unsigned int hand[]); // return true if hand is a full house and false otherwise
int main(void)
{
// define and initialize deck array
unsigned int deck[CARDS];
// initialize deck with values 0 to CARDS-1
// value /13 caluclates suit # { "Hearts", "Diamonds", "Clubs", "Spades" };
// value %13 calculates face card {Ace,2,3,...10, Jack, Queen, King}
for (size_t card =0; card CARDS; ++card)
{
deck[card]= card;
}
srand((unsigned int)time(NULL)); // seed random-number generator
// initialize suit array
const char* suit[SUITS]=
{ "Hearts", "Diamonds", "Clubs", "Spades" };
// initialize face array
const char* face[FACES]=
{ "Ace", "Deuce", "Three", "Four",
"Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King" };
/*
shuffle(deck); // uncomment after completing the implementation
// of the swap() and shuffle() functions
*/
deal(deck, face, suit); // display the deck unshuffled
unsigned int hand[HAND_SIZE]; // will contain the cards in the hand.
//Define and initialize variables used to count each type of hand
unsigned int pairCount =0;
unsigned int twoPairCount =0;
unsigned int threeOfAKindCount =0;
unsigned int straightCount =0;
unsigned int flushCount =0;
unsigned int fullHouseCount =0;
unsigned int fourOfAKindCount =0;
unsigned int straightFlushCount =0; //NOTE: This count includes both straight flushes and royal flushes.
// Shuffle the deck for the first time
// After this, we shuffle deck every time we do not have enough undealth cards
// for a complete hand which will be every 10 deals assuming five card hands
shuffle(deck);
// Deal out NUMBER_OF_HANDS_PLAYED hands
for (size_t hands =1; hands NUMBER_OF_HANDS_PLAYED; ++hands)
{
dealNextHand(deck, hand); // Deal out next 5 cards from the deck into the array hand
// Does hand have a pair?
if (isPair(hand))
{
++pairCount; // Yes, increment pair count
}
// Does hand have two pair?
if (isTwoPair(hand))
{
++twoPairCount;
}
// Does hand have three of a kind?
if (isThreeOfAKind(hand))
{
++threeOfAKindCount;
}
// Does hand have a straight?
if (isStraight(hand))
{
// Check if also a flush
if (isFlush(hand))
{
++straightFlushCount; //both straight and flush
}
else
{
++straightCount; // nope, just a straight
}
}
// Does hand have a flush?
if (isFlush(hand))//not a straight, how about a flush?
{
++flushCount;
}
// Does hand have a full house?
if (isFullHouse(hand))
{
++fullHouseCount;
}
// Does hand have four of a kind?
if (isFourOfAKind(hand))
{
++fourOfAKindCount;
}
}
// Display all of the cards in the deck
void deal(const unsigned int wDeck[], const char* wFace[],
const char* wSuit[])
{
// deal each of the cards
for (size_t card =0; card CARDS; ++card){
size_t suit = wDeck[card]/ FACES;
size_t face = wDeck[card]% FACES;
printf("%5s of %-8s%c", wFace[face], wSuit[suit], card %4==3?'
' : '\t');
 ONLY C PROGRAMMING... I PROVIDE YOU CODE HERE AND FUNCTIONS THAT

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!