9 6 0 5 0 0 0 8 3
3 0 0 2 7 9 0 0 4
0 0 2 6 0 0 0 9 0
0 9 0 0 0 6 7 0 0
7 4 0 0 0 0 0 5 1
0 0 8 4 0 0 0 2 0
0 7 0 0 0 5 4 0 0
6 0 0 9 1 4 0 0 5
5 1 0 0 0 8 0 3 2
and then enter each value into a 2d array - rooms[9][9], which was declared in rooms.h:
'static int Game::rooms[9][9];'
and defined with the line in rooms.cpp:
'int Game::rooms[9][9];'
The definition of read() function was placed in rooms.cpp:
Expand|Select|Wrap|Line Numbers
- void Game::Read(string n)
- {
- string Name = n;
- ifstream I;
- I.open(Name.c_str());
- while (!I.eof())
- {
- int Num;
- for (int i=0; i<r; i++)
- {
- for(int j=0; j<c; j++)
- {
- I >> Num;
- rooms[i][j] = Num;
- }
- }
- }
- I.close();