Urgent Help Needed (C++)

Ok...so I'm working on the famous eightqueens problem.

I've coded up the algorithm with goto statements.

Now my instructor wants to do the same thing but without goto statements.

You can use functions, while loops, break, and continue.

I've tried coding this for about three days now, and I'm stuck on writing the functions and knowing where to locate them in the main program.

So anyone here can give me some advice, hints, etc.

Thanks in advance.

Last edited on
#include <iostream>
using namespace std;


bool okay(int q[], int col){
if ( q[] == 8) {
return false;
else {
return true;
}

void print(int q[], int s){


}
void backtrack(int q[], int col){


}
int main () {
int q[8] ,c ,i ,j;
int cntr = 0;
q[0] = 0;
c =0;
c++;
while (c ==8) {
cntr++;
print(q,8);
break;
cout << "Solution# " << cntr << ": ";
continue;
}
q[c] = -1;

q[c]++;

while ( q[c] == 8 ){ break;
backtrack(q,c);
c--;
if ( c== -1) exit (0);
continue;
/***********************************************
for (i -0 ; i <c ;i ++)
if (q[i] ==q[c] || c-i == abs(q[c] - q[i]) )
**********************************************/
//put in ok function
okay(q,c);
cout << "Solution# " << cntr << ": ";
for ( i= 0 ; i <8 ; i++ )
cout << q[i] << " " ;
cout << endl;
break;
c--;
if ( c == -1 ) exit (0);
}
return 0;
}
I need help ASAP!

Thanks in advance.

NOTE:Above is what I have so far, not the final version.
Please can anyone help me!

This is urgent.
post the code with the goto statements, its easier to translate code using different methods than to learn the actual problem
Topic archived. No new replies allowed.