Click here to Skip to main content
11,707,167 members (49,973 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# logic
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.
Posted 25-Aug-12 16:09pm
@amitgajjar at 25-Aug-12 22:26pm
have you tried anything ?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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;

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
-Amit Gajjar
agha_ali22 at 25-Aug-12 23:10pm
thanks for diagonal solution, so i have to make 12 checks(5 rows,5 cols,2 diagonal) and increment an index and if its 5 return it
@amitgajjar at 25-Aug-12 23:49pm
if you think deeply then you can do that with two functions only. one for diagonal and second for rows/columns. if you change above diagonal's if condition then it will work for both diagonal. change it with if(abc[i,j] != true || abc[i,i] != true)

I am glad it answers your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 145
1 OriginalGriff 141
2 chainerlt 110
3 Maciej Los 80
4 ppolymorphe 79
0 OriginalGriff 9,178
1 Sergey Alexandrovich Kryukov 8,512
2 CPallini 5,189
3 Maciej Los 4,766
4 Mika Wendelius 3,696

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 25 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100