- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面的程序假设正在寻找“对子”和“同花”。它迭代 10 次试验,包括 10,000 手牌,每手牌由 5 张牌组成。结果应该(当然现在不是)由 10 行组成,反射(reflect)每个试验的独特结果。我卡住了...提前致谢。
#include "card.h"
#include "deck.h"
#include "game1.h"
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;
int main() {
int pair = 0;
int flush = 0;
int h; //Hands
int c; //Cards
int t; //Trials
const int MAXTRIALS = 10;
const int MAXHANDS = 10000;
const int MAXCARDS = 5;
const int MAXSHUFFLE = 100;
Deck myDeck;
Card myCards[MAXCARDS];
myDeck.shuffle(MAXSHUFFLE); //How often would you shuffle?
srand((unsigned)time(NULL)); //Randon initilizer
for (t = 0 ; t < MAXTRIALS; ++t) //Outermost loop for the Trials
{
for (h = 0; h < MAXHANDS; ++h) //InnerLoop for Hands
{
myCards[0] = myDeck.getCard();
for (c = 1; c < MAXCARDS; ++c) //InnerMost Loop for Cards
{
myCards[c] = myDeck.getCard();
if (myCards[c].getValue() == myCards[0].getValue())
{
pair++;
}
if (myCards[c].getSuit() == myCards[0].getSuit())
{
flush++;
}
myDeck.addCard(myCards[c]);
c++;
}
myDeck.shuffle(MAXSHUFFLE);
h++;
}
cout << "pairs: " << pair << "\tflushes: " << flush << endl;
}
cin.get();
}
最佳答案
如果我理解你的问题,“结果应该......由 10 行组成,反射(reflect)每次试验的独特结果”,问题很简单,你没有重置 对
和 flush
每次试验之间的计数器变量。像下面这样的“试用”for
循环开始的地方应该可以解决问题:
for (t = 0 ; t < MAXTRIALS; ++t)
{
pair = 0;
flush = 0;
// the remainder as is...
关于C++ 需要帮助遍历卡片、定位对子和同花顺,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6619530/
让我们开始吧,3 个类(Card、Start、Deckofcards) 1° 卡: public class Card { private String type; private i
我要创建一个二十一点游戏,我正在尝试弄清楚如何发牌并让它显示值和名称。我选择两个属性的原因纯粹是基于逻辑,当涉及到将 A 视为 1 或 11 时。还没有达到这一点,只是想如果有人想知道的话我会包括在内
我正在尝试使用 twitter 元标记(以及 Facebook 等其他网站的 Open Graph)创建 Twitter 卡片。当我看到来自其他人(例如 NPR 新闻)的推特提要时,卡片会默认展开。
我正在开发一个玩基本扑克游戏的程序,但这并不重要。我有一组 52 张牌,包含花色和等级。我想打印 4 行 13 行的值(花色和等级)。这可能是一个简单的问题,但我整天都在努力解决这个问题。因此,我非常
我开发了一个包含三列(两列相等,一列较小)的网格。我的问题是我无法在卡片上设置高度,我在 px 中使用了它们并且它起作用了,但这不是最好的方法。我希望这三列具有相同的高度(页面的 100%)并且一些卡
我在 4 个不同的列中开发了 4 个 Bootstrap 卡。在每张卡片中,我创建了一张包含某种类型信息的新卡片。 我的问题是,当我缩小屏幕尺寸(响应测试)时,文本会从卡片中溢出。我的问题是什么,我该
我怎样才能达到 固定高度 具有垂直可滚动 的 bootstrap 4 卡卡片文字部分? Card title This portion and
在我的程序中,我有一个大 Canvas ,我在其中提取多个选定区域并将这些区域绘制到单独的新小 Canvas 上。 我想使用此 API 将新创建的 Canvas 作为附件发布到 trello POST
我想在卡片 View 中显示联系信息,如果需要,应该调整卡片 View 的大小以包含所有信息。 这是布局部分: 但是 an
这是我的card_view。我已经提到了 card_view:cardElevation。但是仍然没有显示阴影。 我搜索了很多链接。他们在任何地方都提到要使用 card_view:cardElevat
我正在使用此处的框架 - cardsui 如何在卡片顶部添加分享按钮。我已经使用点击方法在 xml 中实现了它,但是当我按下它时应用程序崩溃并说该方法不存在(是的,我将该方法添加到主 java 文件中
我正在将 cardview 与 recycler view 一起使用。但早些时候我使用相同的代码来做事没有任何问题。但现在我正在使用 fragment 。现在我得到卡片 View 之间的距离更大。我的
我的卡片 View 设置如下: android:layout_marginTop="2dp" android:layout_marginLeft="6dp" android:layout_margin
我正在制作一个二十一点游戏,并创建了一个数组来充当用户发牌的手牌。我希望能够对其进行排序,以便手按数字顺序排序,这样可以更简单地确定用户的手的类型。这是我的卡片结构: struct ACard{
我希望在一个运行在 Wordpress 上的网站上实现 Twitter Cards(关于 Twitter Cards 的文档在这里:https://dev.twitter.com/docs/cards
我需要帮助解决这个难题。在 bootstrap 4.1 中使用卡片列和卡片时,当我不想这样做时,行会中断。我将列数设置为 4,当有 4 张卡片时,它看起来很完美。当添加第五张牌时,它会将行分成顶部的
我有一个 android ListView ,它显示类似卡片的 View ,正如您在这张图片中看到的,我的卡片之间有一条灰色细线: 我怎样才能摆脱灰线? 我实现这个卡片 View 的xml是这样的:
我正在尝试添加带有回收站 View 的卡片 View 。但它没有显示任何内容,只是一个空白 View 。 我在这里看到了这方面的问题,它有为回收站 View 和卡片 View 添加依赖项的答案。这出现
我在 android 中通过回收站 View 实现卡片 View ,但我的卡片 View 没有显示。我正在使用自定义适配器将数据填充到卡片 View 。我已经尝试了所有方法,但没有显示卡片 View
在我的应用程序中,我有一个卡片 View ,其中包含一个 TextView 和一个按钮,该按钮最初是隐藏的,当单击卡片 View 时,会显示该按钮。我不知道如何在显示按钮时将其设置为动画。任何人都可以
我是一名优秀的程序员,十分优秀!