41、随机数生成:从均匀分布到正态分布的探索

随机数生成:从均匀分布到正态分布的探索

1. 扑克牌分发示例

在编程中,我们常常会遇到需要模拟随机事件的情况,扑克牌分发就是一个很好的例子。以下是相关代码:

// Definition of init_deck() to initialize a deck to a full set of 52 cards here...
// Definition of deal() that deals a complete deck here...
// Definition of sort_hands() to sort cards in hands here...
// Definition of show_hands to output all hands here...

int main()
{
  // Create the deck
  Deck deck;
  init_deck(deck);

  // Create and deal the hands
  Hands hands(4);
  deal(hands, deck);

  // Sort and show the hands
  sort_hands(hands);
  show_hands(hands);
}

执行这段代码后,可能会得到如下手牌展示:

3C  9C 10C  QC  AC  2D  3D  9D  QD  2H  6H  JS  QS
2C  4C  6D  8D  JD  KD  3H  8H  9H  KH  9S 10S  KS
5C  6C  8C  5D  AD  5H 1
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值