0

bool won(void) {

for(int i= 0; i<d; i++)
{
    for(int j = 0; j <d; j++)
    {
        if((i==(d - 1)) && (j==(d -1)) && board[i][j]== 0)
        {
           if(board[i][j] < board[i][j+1] )
        {
            return true;
        }
        }
    }
}
// TODO
return false;

}

I am getting an error which says timed out while waiting for program to exit. Can somebody please help me with what could possibly be my mistake here? Thank you! :)

1 Answer 1

0

You should not return true within the loop. Within the loop, check whether the tile is what it is meant to be (you could use for example a counter or a closed formula), and return false if not. Only after the loop, when you've checked all numbers, return true.

Also, accessing board[i][j+1] is not a good idea if you don't check first that board[i][j+1] is on the board.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .