Question: ( 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!