ive been having a few problems writing this program,
the problem is to place 8 queens on a chessboard in such a way that no queen can take any other queen.
in our assignment we are supposed to implement the board using a one dimensional array in which the array position is the column and the value at said position is the row in which the queen will be place on that column.
in my last build i got a print out with an "incorrect" answer.
I changed the ok function slightly to mirror what my instructor used in his outline.
at this point my program compiles but does not run or does not run properly, i would appreciate any input as to what is wrong with the program and how i may be able to correct it so as to have "correct" output
this is the program as it stands right now:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main (){
int q[8]={0};
int col=0;
q[0]=1;
col ++;
bool frombacktrack=0;
bool good=0;
while (true){ //first loop
while (col <8){ // second loop
if (frombacktrack){
q[col]++;
frombacktrack=0;
}
while ( q[col] <8) {
if ( ok (q,col)){
good=1;
break;
}
q[col]++;
}
if (good){
col++;
good=0;
continue;