Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ / JUST C PROGRAMMING.. FOLLOWING CODE IS GIVEN JUST WRITE CODE FOR LAST 3 FUNCTIONS.... #include #include #include #define SUITS 4 #define FACES 1

// JUST C PROGRAMMING.. FOLLOWING CODE IS GIVEN JUST WRITE CODE FOR LAST 3 FUNCTIONS....
#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
int isFourOfAKind(const unsigned int hand[]);
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[]);
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" };
unsigned int twoPairCount =0;
unsigned int threeOfAKindCount =0;
}
int isFourOfAKind(const unsigned int hand[])
{
unsigned int faceCnt[FACES]={0};
// Calculate the frequency of each face card in the hand
// In other words, it calculates how many Aces, deuces, 3's, etc. in the hand of 5 cards
for (size_t card =0; card < HAND_SIZE; ++card)
{
++faceCnt[hand[card]% FACES];
}
// Iterate through all of the frequency counts to find out if
// any face card occurred 4 times in the hand
for (size_t face =0; face < FACES; ++face)
{
if (faceCnt[face]==4)
{
return TRUE; // Yes!!! Return true.
}
}
return FALSE; //Nope ;-(
}// Returns true if hand contains only a pair and false other wise
// NOTE: Will return FALSE if the hand contains any of these hand types as well:
//1) Hand has 2 pairs
//2) Hand has 3 of a kind
//2) Hand is a full house
//3) Hand has 4 of a kind
int isPair(const unsigned int hand[])
{
// Student implements this function
return FALSE;
}
// Returns true if hand contains two pairs and false otherwise
// NOTE: Will return FALSE if the hand contains any of these hand types as well:
//1) Hand has 3 of a kind
//2) Hand is a full house
//3) Hand has 4 of a kind
int isTwoPair(const unsigned int hand[])
{
// Student implements this function
return FALSE;
}
// Returns true if hand contains 3 of a kind and false otherwise
// NOTE: Will return FALSE if the hand contains any of these hand types as well:
//1) Hand has a full house
//2) Hand has 4 of a kind
int isThreeOfAKind(const unsigned int hand[])
{
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

2. What potential barriers would you encourage Samuel to avoid?

Answered: 1 week ago