- Beranda
- Komunitas
- Tech
- Programmer Forum
Help! Tugas codingan C


TS
bambang150
Help! Tugas codingan C
pLEASE HELP AGAN-AGAN YANG BISA NYUMBANGIN JAWABANNYA ATAU DAPAT MENCERAHKAN :d
Spoiler for tUGAS:
7.12 (Card Shuffling and Dealing) Modify the program in Fig. 7.24 so that the card-dealing
function deals a five-card poker hand. Then write the following additional functions:
a) Determine if the hand contains a pair.
b) Determine if the hand contains two pairs.
c) Determine if the hand contains three of a kind (e.g., three jacks).
d) Determine if the hand contains four of a kind (e.g., four aces).
e) Determine if the hand contains a flush (i.e., all five cards of the same suit).
f) Determine if the hand contains a straight (i.e., five cards of consecutive face values).
7.13 (Project: Card Shuffling and Dealing) Use the functions developed in Exercise 7.12 to
write a program that deals two five-card poker hands, evaluates each hand, and determines which is
the better hand.
7.14 (Project: Card Shuffling and Dealing) Modify the program developed in Exercise 7.13 so
that it can simulate the dealer. The dealer's five-card hand is dealt “face down” so the player cannot
see it. The program should then evaluate the dealer’s hand, and based on the quality of the hand,
the dealer should draw one, two or three more cards to replace the corresponding number of unneeded
cards in the original hand. The program should then re-evaluate the dealer's hand. [Caution:
This is a difficult problem!]
7.15 (Project: Card Shuffling and Dealing) Modify the program developed in Exercise 7.14 so
that it can handle the dealer’s hand automatically, but the player is allowed to decide which cards
of the player's hand to replace. The program should then evaluate both hands and determine who
wins. Now use this new program to play 20 games against the computer. Who wins more games,
you or the computer? Have one of your friends play 20 games against the computer. Who wins more
games? Based on the results of these games, make appropriate modifications to refine your poker
playing program (this, too, is a difficult problem). Play 20 more games. Does your modified program
play a better game?
7.16 (Card Shuffling and Dealing Modification) In the card shuffling and dealing program of
Fig. 7.24, we intentionally used an inefficient shuffling algorithm that introduced the possibility of
indefinite postponement. In this problem, you’ll create a high-performance shuffling algorithm that
avoids indefinite postponement.
Modify the program of Fig. 7.24 as follows. Begin by initializing the deck array as shown in
Fig. 7.29. Modify the shuffle function to loop row-by-row and column-by-column through the
array, touching every element once. Each element should be swapped with a randomly selected element
of the array. Print the resulting array to determine if the deck is satisfactorily shuffled (as in
Fig. 7.30, for example). You may want your program to call the shuffle function several times to
ensure a satisfactory shuffle.
Although the approach in this problem improves the shuffling algorithm, the dealing algorithm
still requires searching the deck array for card 1, then card 2, then card 3, and so on. Worse
yet, even after the dealing algorithm locates and deals the card, the algorithm continues searching
through the remainder of the deck. Modify the program of Fig. 7.24 so that once a card is dealt, no
function deals a five-card poker hand. Then write the following additional functions:
a) Determine if the hand contains a pair.
b) Determine if the hand contains two pairs.
c) Determine if the hand contains three of a kind (e.g., three jacks).
d) Determine if the hand contains four of a kind (e.g., four aces).
e) Determine if the hand contains a flush (i.e., all five cards of the same suit).
f) Determine if the hand contains a straight (i.e., five cards of consecutive face values).
7.13 (Project: Card Shuffling and Dealing) Use the functions developed in Exercise 7.12 to
write a program that deals two five-card poker hands, evaluates each hand, and determines which is
the better hand.
7.14 (Project: Card Shuffling and Dealing) Modify the program developed in Exercise 7.13 so
that it can simulate the dealer. The dealer's five-card hand is dealt “face down” so the player cannot
see it. The program should then evaluate the dealer’s hand, and based on the quality of the hand,
the dealer should draw one, two or three more cards to replace the corresponding number of unneeded
cards in the original hand. The program should then re-evaluate the dealer's hand. [Caution:
This is a difficult problem!]
7.15 (Project: Card Shuffling and Dealing) Modify the program developed in Exercise 7.14 so
that it can handle the dealer’s hand automatically, but the player is allowed to decide which cards
of the player's hand to replace. The program should then evaluate both hands and determine who
wins. Now use this new program to play 20 games against the computer. Who wins more games,
you or the computer? Have one of your friends play 20 games against the computer. Who wins more
games? Based on the results of these games, make appropriate modifications to refine your poker
playing program (this, too, is a difficult problem). Play 20 more games. Does your modified program
play a better game?
7.16 (Card Shuffling and Dealing Modification) In the card shuffling and dealing program of
Fig. 7.24, we intentionally used an inefficient shuffling algorithm that introduced the possibility of
indefinite postponement. In this problem, you’ll create a high-performance shuffling algorithm that
avoids indefinite postponement.
Modify the program of Fig. 7.24 as follows. Begin by initializing the deck array as shown in
Fig. 7.29. Modify the shuffle function to loop row-by-row and column-by-column through the
array, touching every element once. Each element should be swapped with a randomly selected element
of the array. Print the resulting array to determine if the deck is satisfactorily shuffled (as in
Fig. 7.30, for example). You may want your program to call the shuffle function several times to
ensure a satisfactory shuffle.
Although the approach in this problem improves the shuffling algorithm, the dealing algorithm
still requires searching the deck array for card 1, then card 2, then card 3, and so on. Worse
yet, even after the dealing algorithm locates and deals the card, the algorithm continues searching
through the remainder of the deck. Modify the program of Fig. 7.24 so that once a card is dealt, no
0
1.4K
Kutip
1
Balasan


Komentar yang asik ya
Urutan
Terbaru
Terlama


Komentar yang asik ya
Komunitas Pilihan