So I've written the code for two of the functions in "fifteen", but after I compiled and started the program it prints a bunch of zeros. I'm hoping for a tip from you guys. The code for the two functions:
/**
* Initializes the game's board with tiles numbered 1 through d*d - 1
* (i.e., fills 2D array with values but does not actually print them).
*/
void init(void)
{
for(int i = 0; i < d; i++)
{
int k = i + 1;
for(int j = 0; j < d; j++)
{
board[i][j] = d * d - (k *(j + k));
}
}
if(d == 4 || d == 6 || d == 8)
{
int swap = board[d - 1][d - 2];
board[d - 1][d - 3] = board[d - 1][d - 2];
board[d - 1][d - 3] = swap;
}
}
/**
* 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(i == d - 1 && j == d - 1)
{
printf("%d", board[i][j] - 2);
}
else
{
printf("%2d", board[i][j]);
printf(" ");
}
}
printf("\n");
}
}