I didn't get the algorithm(logic) you used to tackle the problem.
Lets take a look, this is the configuration depicting the already won game.
To implement the
won() function, we need check whether each tile is placed at its corresponding index. For this, we need to check the value of each and every
board[rth_row][cth_column] by traversing(moving) from
board[d-1][d-1]. This can be done as
for (i = 0 ; i < d ; ++i)
for (j = 0 ; j < d ; ++j)
// do check for the value of board[i][j]
You can set another variable(say
1 before the loops, and increment it by one inside the inner loop so that you can check the value of
counter. If the values aren't equal, then you can return
false, no else part should be there for now. At the end of the function, you can simply return
true because execution will fall out of the loop only and only if each and every
board[i][j] has the expected value.
But there is a problem, I have not mentioned a corner case. Find it yourself and also tackle it. Best of Luck.