From the course: Code Clinic: C++

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Draw the board

Draw the board - C++ Tutorial

From the course: Code Clinic: C++

Start my 1-month free trial

Draw the board

- [Instructor] I needed a way to display the results of my program. But since creating a GUI with C++ isn't as easy as some other languages like Python, I decided to keep it simple. So I chose to display solutions on the command prompt as ASCII art using the vertical bar, spaces, and the letter Q to build up the board. My printBoard function starts at line 76. And I start off with displaying the values in the board array representing the position of queens on lines 83 and 87. The first value corresponds to which column the queen is located within the first row. The second value is the column in the second row and so forth. Next, to draw the board and the queens, I used a for loop which begins at line 90. First, I draw a set of dashed lines to outline the top of the board. The for loop at line 95 goes through the rows of the board and the second for loop at line 98 draws the squares of the board. As the second for…

Contents