Hello Everybody ,
i have array of size 9x9 i want to write a function to Check each 3x3 box

Recommended Answers

All 5 Replies

OK, why don't you? We can't wait to see the results.

This sounds like some sort of Sudoku type problem. Researching C++ source code for Sudoku should give you some samples to work with.

u r right .... i made function to check rows and another one one to check column and i cannot made one to check each box if u can help give me any hint xD

Starting with a 9X9 array(row,column)
One way is with another 9X9 array(square,cell), but this one arranged by each 3X3 square. Assuming the squares and the 3X3 cells can be indexed like:

0 1 2
3 4 5
6 7 8

Each row/column coordinate of the original array can be used to place each cell in the appropriate place in the new array.

The index of the square that a cell belongs in can be calculated with:

((column / 3) + (row / 3)) + ((row / 3) * 2)

The index of a cell inside the square can be calculated with:

((column  % 3) + (row % 3)) + ((row % 3) * 2)

thank yo i appreciate ur help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.