void init(void)
{
int grid = (d * d) - 1;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
board[i][j] = grid;
grid--;
}
}
if ((d * d) % 2 == 0)
{
int temp = board[d - 1][d - 2];
board[d - 1][d - 2] = board[d - 1][d - 3];
board[d - 1][d - 3] = temp;
}
}
/**
* Prints the board in its current state.
*/
void draw(void)
{
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (board[i][j] == 0)
{
printf(" ");
}
else
printf("%i",board[i][j]);
}
}
printf("\n");
}
When I run the program, the board is not 2d, but 1d.