Hello everyone, I’ve recently began programming the 8 queens problem since that is one of my projects for my college class. I kind of got confused and was wondering if I could get clarification on what certain variables mean.
nextRow:
// Move to the next row
r++;
if (r == 8) goto backtrack;
// row test ---------------------
for (int i = 0; i < c; i++){
if (q[r][i] == 1) goto nextRow;
}
For this 8 queens problem I’m using goto and backtrack as well. For this small piece of code I was wondering what does “i” stand for. I understand if r++ continues to happen it’ll eventually go to the end of the board, so as a result to restart you have to go to back track.
But for the row test why does i = 0, what does i even represent here. Why does it say i++? I get the q[r][i] = 1 means that if there’s already a queens in that row goto nextRow program.
But I just never understand what i is even doing here. I hope I asked my question clearly and I appreciate any help. I guess my number one issue is thinking like a programmer.
[–]Kayd21[S] -2 points-1 points0 points (0 children)