Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( Similar to the problem above, but the user specifies a row for each column instead of a column for each row. ) Eight queens

(Similar to the problem above, but the user specifies a row
for each column instead of a column for each row.) Eight queens are to be
placed on a 8 x 8 chessboard in such a way that one queen is to be placed in each column. Write a complete C++ program that does the
following:
Declare an array queenRows[] with capacity 8 to represent such a configuration.
If queenRows[c] has value r then in column c there is a queen in row r.
The program should ask the user to enter the row that contains queens in the 8 rows.
The program then passes array queenRows to a f
unction called printBoard that prints a 2D board with . in the non-queen row of each
row and Q in the queen row of each column.
Example main f
unction that uses these f
unctions:
int main(){
int queenRows[8];
cout << "Enter rows for queens:
";
readInput(queenRows,8);
printBoard(queenRows,8);
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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

calculate the formula masses of Nitrogen dioxide

Answered: 1 week ago