My code for won seems have correct logic but is not working.I could only check for 9 tile game as I only solved this so far but gametes not break out of loop and asks again tilt move after the winning configuration.
bool won(void)
{
int checkWon = 0;
int k = 0;
for (int i = 0; i < d; i++)
{
for (int j = 1; j <= d; j++)
{
if (board[i][j] != (i+j+k)%(d*d))
{
checkWon = 1;
}
}
k = k+d-1;
}
if (checkWon == 0)
return true;
else
return false;
}