65.9K
CodeProject 正在变化。 阅读更多。
Home

检查德州扑克牌

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.26/5 (9投票s)

2007年3月14日

CPOL

2分钟阅读

viewsIcon

48838

downloadIcon

802

在德州扑克游戏中检查您的牌。

引言

这个程序可以告诉你,在德州扑克游戏中,根据你拥有的7张牌,你拥有什么样的牌型。

背景

我试图创建一个程序来计算德州扑克游戏的胜率,而最困难的部分是找到一个检查牌型类型的代码。因此,我决定编写一个专门执行此操作的程序。

使用代码

我尽可能地使代码易于阅读。

代码的每个部分都有很多注释来解释其作用。

函数 checkHand() 中的一些代码是冗余的。我这样做是为了使函数更易于阅读。

这个程序中的函数包括

int main()
void checkPokerHand(int hand[], int card1, int card2);
string checkCard(int card);
string checkSuit(int card);
void sort(int a[]);

main() 询问牌并显示最佳牌型。

checkHand() 接收一个大小为14的整数数组。

hand[#] 发送 返回
hand[0] 0

扑克牌型

8 = 同花顺
7 = 四条
6 = 葫芦
5 = 同花
4 = 顺子
3 = 三条
2 = 两对
1 = 一对
0 = 高牌

hand[1] 0

对子牌
(例如,四条2 = 2)

两对
高对子

hand[2] 0

高牌

两对
低对子

hand[3] 0 手牌中第二高的牌
hand[4] 0 手牌中第三高的牌
hand[5] 0 手牌中第四高的牌
hand[6] 0 手牌中最低的牌
hand[7] card1 最低牌
hand[8] card2 第二低牌
hand[9] card3 第三低牌
hand[10] card4 第四高牌
hand[11] card5 第三高牌
hand[12] card6 第二高牌
hand[13] card7 最高牌

card1 是你两张牌中最高的牌。

card 2 是你两张牌中最低的牌。

checkCard(int card) 返回一个字符串形式的牌面值
(例如,2 返回 "2" - 14 返回 "A")

checkSuit(int card) 返回一个字符串形式的牌的花色
(例如,1 返回 "红桃"; 2 返回 "梅花"; 3 返回 "方块"; 4 返回 "黑桃";)

历史

版本 1.0
检查给定7张牌的最佳扑克牌型。

© . All rights reserved.