1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
// The size of an array in C++ has to be constant but some compilers
// accepts it anyway. The names x and y sounds like coordinates,
// naming them width and hight might make more sense. In that case
// you can use x and y as names instead of i and n because they are
// actually coordinates.
const int x = 10;
const int y = 10;
// You can initialize the grid this way
int grid[y][x] =
{
8, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 0, 1, 1, 1, 1, 1, 1, 0,
0, 1, 0, 1, 0, 0, 0, 0, 1, 0,
0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
0, 1, 0, 1, 1, 1, 0, 1, 1, 0,
0, 1, 0, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 1, 1, 1, 0, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
|