Learn to Code
John F. Dumas
contact me | resume | how it works | example programs | testimonials | main page
C++ - Reflect
► Problem Description: Write a c++ program that can find all the ways 'N' queens can be placed on a chessboard such that no queen can capture any other. Allow the user to pass the value of 'N' as a command line argument, ensure the code works properly on both windows and unix.
► Example Usage:
n-queens 8 --------------------------- Solution: 1 --------------------------- [Q][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][Q][ ] [ ][ ][ ][ ][Q][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][Q] [ ][Q][ ][ ][ ][ ][ ][ ] [ ][ ][ ][Q][ ][ ][ ][ ] [ ][ ][ ][ ][ ][Q][ ][ ] [ ][ ][Q][ ][ ][ ][ ][ ] --------------------------- Solution: 2 --------------------------- [Q][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][Q][ ] [ ][ ][ ][Q][ ][ ][ ][ ] [ ][ ][ ][ ][ ][Q][ ][ ] [ ][ ][ ][ ][ ][ ][ ][Q] [ ][Q][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][Q][ ][ ][ ] [ ][ ][Q][ ][ ][ ][ ][ ] --------------------------- Solution: 3 --------------------------- [Q][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][Q][ ][ ] [ ][ ][ ][ ][ ][ ][ ][Q] [ ][ ][Q][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][Q][ ] [ ][ ][ ][Q][ ][ ][ ][ ] [ ][Q][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][Q][ ][ ][ ] ... --------------------------- Solution: 90 --------------------------- [ ][ ][ ][ ][Q][ ][ ][ ] [ ][Q][ ][ ][ ][ ][ ][ ] [ ][ ][ ][Q][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][Q][ ] [ ][ ][Q][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][Q] [ ][ ][ ][ ][ ][Q][ ][ ] [Q][ ][ ][ ][ ][ ][ ][ ] --------------------------- Solution: 91 --------------------------- [ ][ ][Q][ ][ ][ ][ ][ ] [ ][ ][ ][ ][Q][ ][ ][ ] [ ][Q][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][Q] [ ][ ][ ][ ][ ][Q][ ][ ] [ ][ ][ ][Q][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][Q][ ] [Q][ ][ ][ ][ ][ ][ ][ ] --------------------------- Solution: 92 --------------------------- [ ][ ][Q][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][Q][ ][ ] [ ][ ][ ][Q][ ][ ][ ][ ] [ ][Q][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][Q] [ ][ ][ ][ ][Q][ ][ ][ ] [ ][ ][ ][ ][ ][ ][Q][ ] [Q][ ][ ][ ][ ][ ][ ][ ]
► Source code