Hi. I'm not very good at these. I'm working on it. Right now I'm stuck on the following problem. I am trying to figure out how to check the diagonals of an n x n chess board. I don't think I have to do more than figure out a 3 x 3, 4 x 4, or a 5 x 5. I am doing the n-Queens problem. I've been told that my problem can be solved using a nested for loop. I've been trying for a while to figure it out, but can't. This is what I have for the two "main" diagonals:

This works. When I try to figure out one of the other diagonals, I get stuck. I'm not using a nested for loop, and I guess I should be. For instance:Code:int left = 0; int right = 0; for(int i = 0; i < N; i++) { if (data->ary[i][i] == 'Q') left++; if (data->ary[i][(N-1)-i] == 'Q') right++; } if (left > 1 || right > 1) return false;

In a 3 x 3 board, I need to check diagonals 1, 2 and 2, 1. I can't even come up with code that will accomplish this:

I'm trying different things. I hate to be reduced to "trial and error" when trying to figure something out. Any ideas? Thanks, SteveCode:int left2 = 0, right2 = 0; for(int i = 1; i < N; i++) // changed i to 1 { if (data->ary[i][i-1] == 'Q') left2++; // changed i+1 to i-1 if (data->ary[i][N-(i+1)] == 'Q') right2++; // no } if(left2 > 1 || right2 > 1) return false;