随机改组

编程入门 行业动态 更新时间:2024-10-09 11:27:20
本文介绍了随机改组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

拜托,有人帮我这个节目! 我们有一副52张牌,我们选择了一张 随机卡来洗牌将甲板放回甲板上的一些随机的 地方。重复500次,然后考虑洗牌的甲板。选择 从牌组顶部开出5张牌。计算手数 哪个有三种,但不算数手牌有b 四种类型。继续画新手,直到牌组需要重新洗牌或者直到100手牌被抽出。在一个屏幕上输出 100手与那些正好三个一样的人。输出也是 三手牌的总数。 请我真的很困惑。我知道我必须使用函数和 52卡实际上是52个元素的数组。但我不知道 怎么做洗牌抽奖,100手牌的输出和 最后数手牌wyh exactlu 3-of-kind 。我不能指出 一种用于测试手牌的方法。请帮忙。 谢谢!

Please, somebody help me with this program! We have a deck of 52 cards and we shuffle the deck by choosing a random card out of the deck placing it back in the deck at some random place. Repeat it 500 times and then consider the deck shuffled. Choose a hand of 5 cards from the top of the deck. Count the number of hands which have three-of-a-kind but don''t count hands which have four-of-a-kind. Continue to draw new hands until the deck either needs reshuffling or until 100 hands have been drawn. Output on one screen the 100 handswith those having exactly three-of-a-kind. Output also the total amount of three-of-a-kind hands. Please I''m really confused. I know that I have to use functions and the 52 cards are actually an array of 52 elements. But I don''t know how to do the shuffling drawind, the output of the 100 hands and finally counting the hands wyh exactlu 3-of-a-kind. I can''t figure out a method for testing a hand for exactly 3-of-a-kind. Please help. Thank you!

推荐答案

" glowfire"写道: "glowfire" writes: 我们有一副52张牌,我们通过从牌组中选择一张随机牌将牌组拖回甲板,然后将牌放回到牌组中。 />地方。重复500次,然后考虑洗牌的甲板。从甲板顶部选择一张5张牌。计算手数哪个有三种,但不算数手牌有四种。继续画新手,直到牌组需要重新洗牌或直到100手牌被抽出。在一个屏幕上输出 100手与那些正好三个一样的人。输出也是三手牌的总量。 请我真的很困惑。我知道我必须使用功能和52张卡实际上是52个元素的数组。但是我不知道如何做洗牌,100手牌的输出和最终计算手的精确度3-of-kind。我无法弄清楚一种方法,用于测试一只手的三种方法。请帮忙。 We have a deck of 52 cards and we shuffle the deck by choosing a random card out of the deck placing it back in the deck at some random place. Repeat it 500 times and then consider the deck shuffled. Choose a hand of 5 cards from the top of the deck. Count the number of hands which have three-of-a-kind but don''t count hands which have four-of-a-kind. Continue to draw new hands until the deck either needs reshuffling or until 100 hands have been drawn. Output on one screen the 100 handswith those having exactly three-of-a-kind. Output also the total amount of three-of-a-kind hands. Please I''m really confused. I know that I have to use functions and the 52 cards are actually an array of 52 elements. But I don''t know how to do the shuffling drawind, the output of the 100 hands and finally counting the hands wyh exactlu 3-of-a-kind. I can''t figure out a method for testing a hand for exactly 3-of-a-kind. Please help.

你要做的第一件事就是创造一副52张牌。对于三种类型的疯子来说,要求 该卡需要同时具有价值和b 套装。我推荐这种结构用于单卡。 struct card { int nbr; // 0..51 int suit; // 0..3 int pip; // 0..12 }; 鉴于你可以使用模运算符计算套装和点数。 尝试创建代码以创建卡片组并发布代码。如果你这样做, 有人可能会帮你进入下一步。您可能希望 专注于for语句和模运算符。 稍后,您需要能够生成随机数字范围 0..51。网上有很多关于生成随机数 以及改组的指导。

The first thing you must do is create a deck of 52 cards. The requirement for three-of-a-kind madates that the card needs to have both a value and suit. I suggest this structure for a single card. struct Card { int nbr; // 0..51 int suit; // 0..3 int pip; // 0..12 }; Given nbr you can compute suit and pip using the modulo operator. Try creating the code to create a card deck and post the code. If you do, someone will probably help you to the next step. You will probably want to focus on the for statement and the modulo operator. Later on, you will need to be able to generate random numbers in the range 0..51. There is a lot of guidance on the Web for generating random numbers and also for shuffling.

查看这个漂亮的程序。它完全符合您的要求!! 我正在尝试自己制作纸牌游戏。 homecast/~anglewyrm/hat.html Check out this nifty program. It does exactly what you are trying to do!! I''m trying to work with it myself to make a card game. homecast/~anglewyrm/hat.html

glowfire写道: glowfire wrote: 请有人帮我这个程序! 我们有一副52张牌,我们洗牌了通过从甲板上选择一张随机牌,将它放回到甲板上的一些随机的地方。重复500次,然后考虑洗牌的甲板。从甲板顶部选择一张5张牌。计算手数哪个有三种,但不算数手牌有四种。继续画新手,直到牌组需要重新洗牌或直到100手牌被抽出。在一个屏幕上输出 100手与那些正好三个一样的人。输出也是三手牌的总量。 请我真的很困惑。我知道我必须使用功能和52张卡实际上是52个元素的数组。但是我不知道如何做洗牌,100手牌的输出和最终计算手的精确度3-of-kind。我无法弄清楚一种方法,用于测试一只手的三种方法。请帮忙。谢谢! Please, somebody help me with this program! We have a deck of 52 cards and we shuffle the deck by choosing a random card out of the deck placing it back in the deck at some random place. Repeat it 500 times and then consider the deck shuffled. Choose a hand of 5 cards from the top of the deck. Count the number of hands which have three-of-a-kind but don''t count hands which have four-of-a-kind. Continue to draw new hands until the deck either needs reshuffling or until 100 hands have been drawn. Output on one screen the 100 handswith those having exactly three-of-a-kind. Output also the total amount of three-of-a-kind hands. Please I''m really confused. I know that I have to use functions and the 52 cards are actually an array of 52 elements. But I don''t know how to do the shuffling drawind, the output of the 100 hands and finally counting the hands wyh exactlu 3-of-a-kind. I can''t figure out a method for testing a hand for exactly 3-of-a-kind. Please help. Thank you!

我认为以下伪代码效率更高,而且更好 改组。 //一次通过洗牌 for(unsigned i = 0; i< 52; ++ i) cards [i] = cards [Random(0 ,51)]; 因为它是一个家庭作业你可以弄清楚如何使用rand(),RAND_MAX和首先通过 来做随机(0,51)打电话给srand((时间(0))。 除非作业需要提到的愚蠢洗牌。 - Ioannis Vranos http:// www23.brinkster/noicys

更多推荐

随机改组

本文发布于:2023-11-29 18:49:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647299.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!