CS141 Lab
Take Home Assignment 3
N-Queen Problem
Instructor:
Sitanshu Kumar
Due: One hour before your scheduled lab of week May 12 ~ May 16
Assignment:
Here, you are required to write a program of N-queen problem. Suppose
the size of chess board is N*N and we have N queens.
In chess a queen can move in any direction, either along rows,
columns,or diagonals. If it meets another piece then it is able to take
it. For this reason we say that a queen "attacks" a piece if it is on
the same column or diagonal. The N-Queens problem is to
place N queens on a chessboard so that no queen attacks any other.
If N=8, it is the "Eight Queens Problem". It requires to place
8 queens on a standard chessboard so that no queen can attack any other
queen. Two solutions are shown below.

Two solutions to the Eight Queens Problem
Requirement:
- Your program can input N from the command line
- Use recursive method
to solve this problem
- Output all the solutions for N-queen problem
- Output the total number of solutions
Sample Output:
$ main 6 //
(input N=6)
No.1
. Q . . . .
. . . Q . .
. . . . . Q
Q . . . . .
. . Q . . .
. . . . Q .
No.2
. . Q . . .
. . . . . Q
. Q . . . .
. . . . Q .
Q . . . . .
. . . Q . .
No.3
. . . Q . .
Q . . . . .
. . . . Q .
. Q . . . .
. . . . . Q
. . Q . . .
No.4
. . . . Q .
. . Q . . .
Q . . . . .
. . . . . Q
. . . Q . .
. Q . . . .
There are
totally 4 solutions.
Attention:
- Please use the Turn-in System
- Put all the files you want to turn-in in one folder
- Goto: https://www.cs.ucr.edu/
- Click "student", login using your account name and password
- Click "WWWTurnin"
- Choose the class section: "cs141"
- Specify you turn-in folder name
- Turn in
- Write a ReadMe plain text file to explain the design of your
program and how your program works
- Include your name, ID, lab section number, email address in
every files you want to turn in.