Похожие чаты

#Include <stdio.h> #include <stdlib.h> #include <time.h> #define SUITS 4 #define FACES 13 #define CARDS 52 //

prototypes
void shuffle(int deck[][FACES]);
void deal(int deck[][FACES], const char *face[], const char *suit[]);

int main(void) {
// initialize deck array
int deck[SUITS][FACES] = {{0}};

srand(time(NULL)); // seed random-number generator
shuffle(deck); // shuffle the deck

// 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"};

deal(deck, face, suit); // deal the deck
}

// shuffle cards in deck
void shuffle(int deck[][FACES]) {
// for each of the cards, choose slot of deck randomly
for (size_t card = 1; card <= CARDS; card++) {
size_t row = 0; // row number
size_t col = 0; // column number

// choose new random location until unoccupied slot found
do {
row = rand() % SUITS;
col = rand() % FACES;
} while (deck[row][col] != 0);

deck[row][col] = card; // place card number in chosen slot
}
}

// deal cards in deck
void deal(int deck[][FACES], const char *face[], const char *suit[]) {
// deal each of the cards
for (size_t card = 1; card <= CARDS; card++) {
// loop through rows of deck
for (size_t row = 0; row < SUITS; row++) {
// loop through columns of deck for current row
for (size_t col = 0; col < FACES; ++col) {
// if slot contains current card, display card
if (deck[row][col] == card) {
printf("%5s of %-8s %c", face[col], suit[row],
card % 4 == 0 ? '\n' : '\0'); // 2-column format
}
}
}
}
}

int containsPair(int hand[][FACES]) {
for (int )
}

1 ответов

22 просмотра
Raphael-Monterey Автор вопроса

Modify the program so that the card-dealing function deals a five-card poker hand. Then write the following additional functions: a) Determine whether the hand contains a pair. b) Determine whether the hand contains two pairs. c) Determine whether the hand contains three of a kind (e.g., three jacks). d) Determine whether the hand contains four of a kind (e.g., four aces). e) Determine whether the hand contains a flush (i.e., all five cards of the same suit). f) Determine whether the hand contains a straight (i.e., five cards of consecu- tive face values).

Похожие вопросы

Обсуждают сегодня

Какой-то там пердун в 90-х решил, что есть какая-то разная типизация. Кого вообще это волнует?
КТ315
49
Hi. Do we have a raid bot? Why nobody doing raids on X? Even RH mentioned this and nobody paying attention...whats the channel for hex memes? If mods cant run raids just insta...
H
31
Подскажите, а есть vault lite или ченить такое?) А то нужен вольт для похода в вольт, но весит он ~500 мб) как-то многовато для парочки запросов ))
Alexandr Orloff
17
блеать, почему так?? где в роутере это исправляется?
Арсен Маньяков 🇦🇲
16
void terminal_scroll() { memmove(terminal_buffer, terminal_buffer + VGA_WIDTH, buffer_size - VGA_WIDTH); memset(terminal_buffer + buffer_size - VGA_WIDTH, 0, VGA_WIDTH); ...
Егор
47
🌊 Ocean Nodes Dashboard Update 🚀 Hey, Oceaners! First off, a massive round of applause 👏to all of you for the amazing engagement since we launched Ocean Nodes. In just a few ...
KreigDK | Never DM first🌊
3
Всем привет! Подскажите, пожалуйста, в чем ошибка? Настраиваю подключение к MySQL. Либы лежат рядом с exe. Все как по "учебнику"
Евгений
16
А можете как-то проверить меня по знаниям по ассемблеру?
A A
132
Здравствуйте! У меня появилась возможность купить книгу "Изучай Haskell во имя добра!". Но я где-то слышал, что эта книга устарела. Насколько это правда??
E
22
люди, которые используют flameshot, к вам вопрос. Можно-ли поставить хоткей на создание скриншота? В программе есть отдел "горячие клавиши", но там все для редактирования, скр...
ThunDer104
11
Карта сайта