× Home (CS 211) Notes Projects Waxman's Website

Purpose

The goal of this project is to find the solutions to the n number of queens on a nxn board. This project uses dynamic arrays and dynamic memory to accomplish its task. See Dynamic Memory for details.

nQueens function

This function should return the number of solutions for the given board size. Since every time this function is called the array size will be different because of the number of queens being worked with. That means we cannot use a single array with a fixed size. Every iteration of this function, we must create a new array dynamically with n size and the initialized to 0. The code to find the queen is same as in 1D Queens except with a few changes. After finding all the solutions, delete the array and return the solution.

Ok Function

The same ok function from the 1D 8 queens project.


Resource
Template
output
This is to be submitted on blackboard as a .cpp file. File name follows the following format: lastName_firstName.cpp