自动发牌,52张牌,分给4人,数组方法设计一个N-S图。要求:黑桃用S,红桃用H,方块用D,梅花用C。
时间: 2024-03-06 15:50:51 浏览: 166
以下是发牌的N-S图:
```
+----------+
| shuffle |
+----------+
|
v
+----------+
| create |
+----------+
|
v
+----------+
| shuffle |
+----------+
|
v
+----------+
| deal |
+----------+
|
v
+------------+ +------------+ +------------+ +------------+
| player 1 | | player 2 | | player 3 | | player 4 |
+------------+ +------------+ +------------+ +------------+
| S A H 2 D 3 | | S 4 H 5 D 6 | | S 7 H 8 D 9 | | S T H J D Q |
| C K S Q H K | | D A C 2 S 3 | | C 4 D 5 S 6 | | C 7 D 8 S 9 |
| H A D 2 C 3 | | H 4 S 5 C 6 | | H 7 D 9 C T | | H Q S K C A |
| D J C Q S K | | H T D J C K | | S Q H J D A | | C 2 S 3 H 4 |
| ... | | ... | | ... | | ... |
+------------+ +------------+ +------------+ +------------+
```
解释:
1. 首先进行洗牌操作。
2. 创建完整的牌组,包括52张牌。
3. 再次洗牌,保证每次发牌的结果都不同。
4. 将洗好的牌组分配给四个玩家,每个玩家分到13张牌。
5. 每个玩家的牌以N-S图的形式呈现,其中S代表黑桃,H代表红桃,D代表方块,C代表梅花。每个玩家的牌按照点数从小到大排列。
阅读全文
相关推荐














