0

I cant seem to find the bug why my move function is not working for me, any help would be much appreciated

bool won(void) { int counter = 0; // loop for rows to start from one position left of the botttom right cuz in winning config bottom right wud be zero for(int i = d - 1; i < 0; i--) { //loop for column starting with max for(int j = d - 1; j < 0; j--) { // if bottom right is zero than skip through the first iteration if(board[d - 1][d -1] == 0) { j--; } //else //{ // increase counter if test is true(number in descending) and consecutive number starting from one tile left of bottom right. if(board[i][j] > board[i][j -1]) { counter++; } //} } }

// if all the values were in correct descending order counter would be d*d - 1
if(counter == d*d -1)
{
    return true;
}
else
{
    return false;
}    

}

2
  • In the for loop, the condition is that i and j should be >0. But you have used it as < 0. This will result in an infinite loop. Please format the code before asking here. It will be more easy to read. – Anirudh Thatipelli Jun 18 '16 at 11:48
  • Also, if you want help with the move function, you need to post that, not the won function. – Cliff B Jun 19 '16 at 23:06

You must log in to answer this question.

Browse other questions tagged .