I don't understand why the second part of this code doesn't get executed. It within the init function and I expect it to run after the loop. The last tile still returns 0 and with odd number of tiles the swap does't occur.
void init(void)
{
int tileNumber = d*d-1; // Set as highest number on the board
for (int i = 0; i < d ; i++) // Set row
{
for (int j = 0; j < d; j++) // Set collum
{
board [i][j] = tileNumber;
tileNumber--;
}
}
// Set blank space to 99
board [d][d] = 99;
//If odd number of tiles, swap the tiles containing 1 and 2
if ((d == 4) || (d == 6) || (d ==8))
{
board [d][d-1] = 2;
board [d][d-2] = 1;
}
}