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 8I want to implement it as a class so I tried the followingclass: 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 twoqueens threaten each other.a) Implement a one-dimensional integer array of Queen positions for an 8x8 boardwhere 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 arein 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)
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 twoqueens threaten each other.a) Implement a one-dimensional integer array of Queen positions for an 8x8 boardwhere 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 arein 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)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here