Hello, I am having trouble with this question for my c++ homework. How would I go about having it be declared as a class rather than writing it as #include using namespace std: //# define N 8 I want...


Hello, I am having trouble with this question for my c++ homework. How would I go about having it be declared as a class rather than writing it as


#include


using namespace std:


//# define N 8


I want to implement it as a class so I tried the following


class: qColumns (N=8){}


I'm stuck here



 N-Queens.
A Queen on a chessboard can attack any piece in the same column, row or diagonal.
The N-Queens problem is to place n queens on a n x n chessboard such that no two
queens threaten each other.
a) Implement a one-dimensional integer array of Queen positions for an 8x8 board
where indices represent rows and the values represent columns.
For example, this “safe” solution would be {3,6,2,7,1,4,0,5}
. . . Q . . . .
. . . . . . Q .
. . Q . . . . .
. . . . . . . Q
. Q . . . . . .
. . . . Q . . .
Q . . . . . . .
. . . . . Q . .
b) Request values for the array from the console.
c) Implement an output to display the board (see output example).
d) Implement a queensAreSafe function that:
1) Returns false if multiple queens share a column. Note that by design they are
in separate rows (make sure you understand why).
2) Returns false if multiple queens share a diagonal.
3) Returns true if all queens are safe.
e) Program should display if the Queens are safe or not safe.
Example output (input is bold and italicized):
Enter 8 column values: 1 4 2 3 5 7 6 0
. Q . . . . . .
. . . . Q . . .
. . Q . . . . .
. . . Q . . . .
. . . . . Q . .
. . . . . . . Q
. . . . . . Q .
Q . . . . . . .
Queens are not safe!
(3,6,2,7,1,4,0,5, safe figure)

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here