Bingo游戏C ++中的循环问题 [英] Problem with loop in Bingo game C++

查看:89
本文介绍了Bingo游戏C ++中的循环问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为BINGO游戏编写代码。下面的代码显示了一个用随机数填充卡片的功能。每个位置的随机数,B列为0-15; I柱为16-30,N柱为31-45,G柱为46-60,O柱为61-75。这是一个5X5 2D阵列。我有这个功能的问题,它不应该工作。


没有编译错误,但输出只是一个闪烁的光标,也许这是一个无限循环?有人可以帮忙吗。


这是功能代码:

展开 | 选择 | 换行 | 行号

解决方案

您是否尝试使用调试器单步执行该功能?


已尝试调试,但无效。我也搜索了其他解决方案的高低,但仍然没有提出任何结果。


好的我看到%15得到0到14之间的随机数,但我不是看其他列的任何其他%计算。


为什么会这样?


然后你有3个循环。那很奇怪。我本来期待两个。一个用于行,一个用于列。


BTW:%15给出0到14范围内的值.Yoiu需要加1才能获得范围1-15。

I am writing code for the game of BINGO. The code below shows a function that fills the card with random numbers. A random number in each location, 0-15 for B column; 16-30 for I column, 31-45 for N column, 46-60 for G column, and 61-75 in O column. This is a 5X5 2 D array. I am having problems with this function, it isnt working as it should.

No compile error, but output is nothing but a flashing cursor, maybe this is an infinite loop?? can someone help with this.

Here is the function code:

Expand|Select|Wrap|Line Numbers

解决方案

Have you tried stepping through the function using your debugger?


Have tried the debugging, but to no effect. I have also searched high and low for other solutions but still have come up with nothing.


OK I see the %15 to get a random number between 0 and 14 but I don''t see any other % calcuations for the other columns.

Why is that?

Then you have 3 loops. That''s odd. I would have expected two. One for the rows and one for the columns.


BTW: That %15 gives a value in the range 0 to 14. Yoiu need to add 1 to get the range 1-15.


这篇关于Bingo游戏C ++中的循环问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆