7-43 Shuffling Machine (20 分)
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing inadequate shuffles, many casinos employ automatic shuffling machines. Your task is to simulate a shuffling machine.
The machine shuffles a deck of 54 cards according to a given random order and repeats for a given number of times. It is assumed that the initial status of a card deck is in the following order:
S1, S2, ..., S13,
H1, H2, ..., H13,
C1, C2, ..., C13,
D1, D2, ..., D13,
J1, J2
where "S" stands for "Spade", "H" for "Heart", "C" for "Club", "D" for "Diamond", and "J" for "Joker". A given order is a permutation of distinct integers in [1, 54]. If the number at the i-th position is j, it means to move the card from position

该博客介绍了如何使用C语言模拟自动洗牌机,对一副包含54张牌(包括两张Joker)的牌组进行洗牌。根据给定的洗牌顺序和重复次数,通过算法重新排列牌的顺序。文章提供了一个思路,使用两个数组分别存储牌的位置和牌本身,通过一个临时数组进行洗牌操作,并关注了最终输出的格式问题。
最低0.47元/天 解锁文章
422

被折叠的 条评论
为什么被折叠?



