Write a program to analyze a number of poker hands and determine which is best. Each hand consists of five cards, and each card has a suit and a value. Your program should read data for any number of hands of five cards each, evaluate the hands, print out each hand and its rank, and which hand is best. It should also include the Sort function given below in the Hints section. This function is given in an incorrect form. Part of your assignment is to test the function (you can do this in the context of your poker program), find the bugs in it and correct them.
Hands in poker are ranked by overall value according to the following table (spades are S, hearts H, diamonds D, and clubs are C; the third column gives an example):
straight flush | five cards in value order and of the same suit | 2D 3D 4D 5D 6D |
four of a kind | four cards of the same value | 7S 7H 7D 7C 13D |
full house | three cards of one value and two cards of another value | 11S 11D 11C 6S 6H |
flush | five cards of the same suit | 2H 4H 5H 7H 12H 13H |
straight | five cards in value order | 2S 3C 4H 5D 6S |
three of a kind | three kinds of the same value | 1S 1H 1C 2H 8C |
two pairs | two cards of one value and two of another | 9S 9H 5S 5C 10D |
one pair | two cards of one value | 8S 8H 4C 5H 13S |
no value | none of the above | 2H 8C 9H 10C 12D |
Notice that some categories include others. For eaxmple, a straight flush is both a straight and a flush; a full house is three of a kind, two pairs, and one pair.
void Sort(handType Hand) { int T, I, J;
for (I = 0; I < 5; I++) for (J = I; J <= 4; J++) if (Hand[I].Value > Hand[J].Value) { T = H[I].Value; Hand[I].Value = Hand[J].Value; Hand[J].Value = T; } }
Hand in your documents to me (RTH) on May 14th. before 5:00 pm.