CS211 Eight Queens with “Fancy Print” Chessboard solved

$30.00

Category: Tags: , , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (1 vote)

As discussed in class …
Modify the Eight Queens program (1 dimensional array – no goto version) so that it prints out a
chessboard with some “fancy” representation of a queen in the appropriate positions.

How to do it:
In class we went over the code to print out a chessboard. You need to:
1. Augment that code by adding two additional “box”es, wq which represents a picture of a
queen placed in a “white” square, and bq, representing a picture of a queens placed in a “black”
square.

2. After the code that fills the array board[8][8] with the addresses of bb and wb, insert code to
change eight entries in that array to reflect the positions of eight queens on the board. You
will get these positions from a one dimensional array q[8] representing a solution to the eight
queens problem. The change that you make in these eight places is to replace the pointer in board
for one representing either a wq, or bq, as appropriate for that position. You know the eight
positions because, given q[i], i represents the column and q[i] represents the row. You can tell
whether its black or white by looking at the row and column indexes of its position on the board.

3. The code described above (in 2.) goes into the print function. You pass the arrays q and
board to print. In the function you
• modify board using q
• print the picture of the board
• “Clean up” array board, by restoring its original values, to get ready for the next call to
print.