Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview For this assignment, write a C++ program that prints all solutions of the N-queens problem for a given positive value of N. In the

image text in transcribed

Overview For this assignment, write a C++ program that prints all solutions of the N-queens problem for a given positive value of N. In the N-queens problem, the goal is to place N queens on an N-by- N chess board so that no two queens are on the same row, column, or diagonal. Note that there are 2 answers to the 4-queens problem, 92 for 8-queens, and 724 for 10-queens. Don't choose big numbers. The following is one of the solutions to 8-queens problem. Specifications Your program must solve the N-queens problem using a recursive function. You need to implement a ChessPuzzle class with the member data and member functions specified in the following header file (ChessPuzzle.h). #ifndef CHESSPUZZLE_H #define CHESSPUZZLE_H #include #include using namespace std; class ChessRwaste 8 8 public: Sheraluats.lint size = 8); //initializes all entries to o void grint Board const; 7 G bool sankbaseQuest lint row, int col); bool in Baard lint row, int col); void sightQueens(int row, int & solutions); 5 private: vector> board; int N; }; 3 fendif 2 2 Implement all member functions in a separate source code file (e-8., ChessPuzzle.cpp). Test your recursive function using the following test file (ChessPuzzle Main.cpp). #include "Sheaakuzatea." b 9 h int main) { int size; Sout > size; Cheaakuzzle ukuzzis (size); Example Output for 4-queens Problem C:Users\Gaolin Dropbox\NCCUCours... \0x Enter the size of the board: 4 Found n-queens solution # 1 Q 9 Q NO Found n-queens solution # 2 Q WWW int nunha ResRutiana = 0; huxRuazdameight Queena (o, nuuskerlesecutiana); system("pause"); HO Press any key to continue... return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

When and how will strategy reviews take place?

Answered: 1 week ago