Question: please finish the C++ program below #include #include using namespace std; bool ok(int q[], int c) { // Reuse the ok function from your 1D

please finish the C++ program below

#include  #include  using namespace std; bool ok(int q[], int c) { // Reuse the ok function from your 1D 8 queens program. } // This function should return the number of solutions for the given board size (you don't need to print the solutions). int nqueens(int n) { // Dynamically declare an array of size n and initialize the first element to 0. // Reuse the code from your 1D 8 queens program to find the solutions (you may have to make changes). // Delete the array. // Return the number of solutions. } int main() { int n = 12; for (int i = 1; i <= n; ++i) cout << "There are " << nqueens(i) << " solutions to the " << i << " queens problem. "; return 0; } 

and print the results below:

There are 1 solutions to the 1 queens problem. There are 0 solutions to the 2 queens problem. There are 0 solutions to the 3 queens problem. There are 2 solutions to the 4 queens problem. There are 10 solutions to the 5 queens problem. There are 4 solutions to the 6 queens problem. There are 40 solutions to the 7 queens problem. There are 92 solutions to the 8 queens problem. There are 352 solutions to the 9 queens problem. There are 724 solutions to the 10 queens problem. There are 2680 solutions to the 11 queens problem. There are 14200 solutions to the 12 queens problem.

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!