在5x5矩阵中找到填充图案的数量 [英] finding number of filled pattern in an 5x5 matrix
问题描述
我正在制作宾果游戏,并且遇到以下问题
我有一个5x5数组,其中随机放置了类(包含number(1-25)和bool标志)对象,现在我在表中显示了这些数字.当用户单击某个数字时,其相应的标志值将设置为true.现在我想要的是查找所有标志值分别等于true的行,列和对角线的计数.我该如何解决这个问题.
I am making a bingo game and facing the following problem
i have a 5x5 array in which class (contains number(1-25) and a bool flag) objects are placed randomly , now i displayed those numbers in a table. When a user click on some number its corresponding flag value sets to true. Now what i want is to find the count of rows,columns and diagonals that have flag value equals to true across all respectively. How can i solve this problem.
推荐答案
您只需要创建一些逻辑即可完成工作.在这里,人们不会为您提供所有代码,但是在这里,我向您提供了一个示例,您可以做到这一点,
Hi,
You just need to create some logic to get your work done. Here people will not gives you all code but here i am giving you one of the sample how you can do that,
//// This function will check only one diagonal row.
private bool checkDiagonal()
{
int i, j;
for (i = 0, j = 4; i < 5; i++, j--)
{
if (abc[i, j] != true)
{
return false;
}
}
return true;
}
希望您可以为其他人生成类似的功能.您甚至可以将 Modulus运算符用于LINQ函数中的其他行和列值匹配.
祝你好运
谢谢
-Amit Gajjar
Hope you can generate similar function for others. you can even use Modulus operator for other rows and columns value matching in LINQ function.
Best of luck
Thanks
-Amit Gajjar
这篇关于在5x5矩阵中找到填充图案的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!