I'm trying to solve a sudoku checker for a game I'm building in C. Essentially these nested for loops are supposed to check through the smaller boxes of 9 numbers to ensure there are no duplicates. Unfortunately, the continue seems to make the checker not work. :(
123
456
576 -------the "5"s should trip up the function to send the show_banner() warning
The reason the first if statement exists is to make sure that the original coordinate is not check against itself. So, if I just typed the two in the above example, I want the for loops here to check everything, but the two that I typed (And in this case the warning would not be displayed.)
I troubleshooted the for loops and found that when I do eliminate the first if statement the banner does show up properly, but the loops are still checking the inputted value against itself.
i also tried inputting != into the top if statement and then placing the second if statement under the first one, but it still didn't work.
I hopped around the message boards and could not find an answer to this particular dilemma, so please help!!!
for (int k = 0; k < 2; k++)
{
for (int l = 0; l < 2; l++)
{
if (((((g.y/3)*3)+k) == g.y) && ((((g.x/3)*3)+l) == g.x))
{
continue;
}
if (g.board[((g.y/3)*3)+k][((g.x/3)*3)+l] == g.board[g.y][g.x])
{
show_banner("You sure that's a good move?");
show_cursor();
}
}
}