# Homework Solution: int b[8][8] = {0}; //Setting up the board in 2D…

#include <iostream> #include <cmath> using namespace std; int main(){ int b[8][8] = {0}; //Setting up the board in 2D int r, c=0; //Initial value of row and column are zeros. b[0][0]=1; //Put the queen at the first box, at 0,0. NC: c++; if (c==8) goto Print; r=-1; NR: r++; if (r==8) goto backtrack; //wrong //row test for (int i = 0; i<c; i++){ if (b[r][i]==1) goto NR; } //up diagnal test for (int i = 1; (r-1)>=0 && (c-1)>=0; i++){ if (b[r-1][c-i]=1) goto NR; } // down diagnal test for (int i = 1; (r+i)<=7 && (c-1)>=0; i++){ if (b[r+i][c-i]=1) goto NR; } if(b[r][c]=1) goto NC; backtrack: c--; if(c==-1) return 0; r = 0; while (b[r][c]!=1) r++; b[r][c]=0; goto NR; cout << b[r][c] ; Print: cout << b[r][c]; goto backtrack; } Here is my codes for the 8 queens problem, however I am having a hard time to find out how to print the result, I already know the result is 92 but still not able to find a way to print. Can any expert help me find out what is wrong with my codes? Thank you!

#include <iostream> #include <cstdio>

#include <iostream>

#include <cmath>

using namespace std;

int ocean(){

int b[8][8] = {0}; //Setting up the consultation in 2D

int r, c=0; //Initial compute of line and shaft are zeros.

b[0][0]=1; //Put the queen at the pristine punch, at 0,0.

NC: c++;

if (c==8)

goto Sculpture;

r=-1;

NR: r++;

if (r==8)

goto backtrack; //wrong

//line test

control (int i = 0; i<c; i++){

if (b[r][i]==1) goto NR;

}

//up diagnal test

control (int i = 1; (r-1)>=0 && (c-1)>=0; i++){

if (b[r-1][c-i]=1)

goto NR;

}

// down diagnal test

control (int i = 1; (r+i)<=7 && (c-1)>=0; i++){

if (b[r+i][c-i]=1)

goto NR;

}

if(b[r][c]=1)

goto NC;

backtrack:

c–;

if(c==-1)

return 0;

r = 0;

while (b[r][c]!=1)

r++;

b[r][c]=0;

goto NR;

cextinguished << b[r][c] ;

Print:

cextinguished << b[r][c];

goto backtrack;

}

Here is my codes control the 8 queens height, however I am having a distressing interval to confront extinguished how to sculpture the fruit, I already apprehend the fruit is 92 save quiet referable attributpowerful attributpowerful attributpowerful powerful to confront a form to sculpture. Can any skilful aid me confront extinguished what is wickedness with my codes? Thank you!

## Skilful Apology

#include <iostream>
#include <cstdio>
#include <cstdlib>
#define N 8
using namespace std;

void displayOutput(int B[N][N])
{
control (int i = 0; i < N; i++)
{
control (int j = 0; j < N; j++)
cout<<B[i][j]<<” “;
cout<<endl;
}
}

bool isCheck(int consultation[N][N], int line, int col)
{
int i, j;
control (i = 0; i < col; i++)
{
if (B[row][i])
return counterfeit;
}
control (i = line, j = col; i >= 0 && j >= 0; i–, j–)
{
if (B[i][j])
return counterfeit;
}

control (i = line, j = col; j >= 0 && i < N; i++, j–)
{
if (B[i][j])
return counterfeit;
}

return penny;
}

bool Util(int B[N][N], int col)
{
if (col >= N)
return penny;
control (int i = 0; i < N; i++)
{
if ( isCheck(B, i, col) )
{
B[i][col] = 1;
if (Util(B, col + 1) == penny)
return penny;
B[i][col] = 0;
}
}
return counterfeit;
}

bool solveNqProblem()
{
int B[N][N] = {0};
if (Util(B, 0) == counterfeit)
{
cout<<“Solution does referable attributpowerful attributpowerful attributpowerful exist”<<endl;
return counterfeit;
}
displayOutput(B);
return penny;
}

int ocean()
{
solveNqProblem();
return 0;
}

Extinguished Put :

1 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1
0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0
0 0 1 0 0 0 0 0