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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

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 <iostream>

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)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY