sudoku Help

Hey guys im new to C++ and well at the moment i have read in a sudoku puzzle that contains numbers and 0's and integers that are not assigned for a completed puzzle, i use a 2d array to store them but what i need to do and can not figure out is that i have to store them all into 3x3 cell blocks but i can not figures this out and it is putting me behind could anybody shine some light on this or help out??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  const int ROWS = 9;
	const int RowBlock = 3;
    const int COLS = 9;
	const int ColsBlock = 3;
    int Puzzle[ROWS][COLS] = {};
	int Block[ROWS][COLS] = {};
    ifstream file("sudoku_puzzle.txt");

    for(int row = 0; file && row < ROWS; ++row)
        for(int col = 0; file >> Puzzle[row][col] && col < COLS; ++col)
			if(file.get() != ' ') break;
	

	for(int i=0; i<RowBlock; i++)    //This loops on the rows.
	{
		for(int j=0; j<ColsBlock; j++) //This loops on the columns
		{
			cout << Puzzle[i][j]  << "  ";
		}
		cout << endl;
		
	}
cout << endl;
}
bump
still need help

You need to think about the layout differently.
Sudoku is a 3x3 grid of 3x3 grids.

Consider creating a struct or class which is a 3x3 grid.
Then compose the larger puzzle of a 3x3 arragement of these grids.

1
2
3
4
5
6
7
8
9
struct Grid
{  int cell[3][3];
};

struct Puzzle 
{  Grid grid[3][3];
};

Puzzle puzzle;


Topic archived. No new replies allowed.