I'm stuck on the logic in pset3 won() function. Apparently, the function just doesn't return true no matter what. Here is my code.
bool won(void)
{
int n = 1;
//iterate over the board
for (int i = 0; i < d; i++)
{
for(int j = 0; j < d; j++)
{
//check to see if last space is 0
if (board[d-1][d-1] != 0)
{
return false;
}
//check if number increasing
else if (board[i][j] != n)
{
n = n+ (d*i)+j;
return false;
}
}
}
//continue to check last row after this line
return true;
}
Please note that I am including n in hope that, at board[0][0], n =1, board[0][1], n = 1+ 3*0+ 1 =2; board[1][0], n = 1+ 3*1+0 = 4; board [1][1], n = 1+ 3*1+ 1= 5.
Thank you for any help you can offer.