二十一点牌矢量 c++/随机数
我遵循了网站上的一些答案,但仍然有一个问题:在运行程序时生成卡片矢量后,卡片号码完全关闭: 第一张卡:100 第二张牌:22 第三:0 第四:0 第五:28 等等。
这是我的代码:
enum numar {AS=11 ,DOI=2, TREI=3, PATRU=4, CINCI=5, SASE=6, SAPTE=7, OPT=8,
NOUA=9, ZECE=10, VALET=10, DAMA=10, REGE=10,
PrimulNumar=AS, UltimulNumar=REGE};
enum culoare {INIMA, CAROU, NEGRU, TREFLA, PrimaCuloare=INIMA,
UltimaCuloare=TREFLA};
int k=0;
for (int r = PrimulNumar; r <= UltimulNumar; ++r) {
for (int s = PrimaCuloare; s <= UltimaCuloare; s++) {
pc[k]= new Carte((numar)r, (culoare)s, false);
k++;
我应该做什么?
I followed some of the answers here on the site but I still have a problem: after I generate my vector of cards when I run the program the card numbers are totally off:
first card:100
second card:22
third:0
fourth:0
fifth:28
etc.
This is my code:
enum numar {AS=11 ,DOI=2, TREI=3, PATRU=4, CINCI=5, SASE=6, SAPTE=7, OPT=8,
NOUA=9, ZECE=10, VALET=10, DAMA=10, REGE=10,
PrimulNumar=AS, UltimulNumar=REGE};
enum culoare {INIMA, CAROU, NEGRU, TREFLA, PrimaCuloare=INIMA,
UltimaCuloare=TREFLA};
int k=0;
for (int r = PrimulNumar; r <= UltimulNumar; ++r) {
for (int s = PrimaCuloare; s <= UltimaCuloare; s++) {
pc[k]= new Carte((numar)r, (culoare)s, false);
k++;
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以......用值替换枚举:
看到问题了吗?
So...replacing enums with values:
See the problem?