eightQueens

# eightQueens - /= / Solves the 8 queens problem: place 8...

This preview shows pages 1–2. Sign up to view the full content.

//================================================================== // Solves the 8 queens problem: place 8 queens on a chessboard such // that no queen can capture any other. This means that no two // queens can be in the same row, same column, or same diagonal. //================================================================== public class Board { //============================================================== // q[i] = the column in which the queen in row i is placed. // Rows and columns are numbered 0 to 7. //============================================================== private int q[]; //============================================================== // Constructor, sets up an array of 8 integers //============================================================== public Board() { q = new int[8]; } //============================================================== // Assumes that the first n queens have been successfully // placed in rows 0 to n-1 and then prints all solutions // that are possible by placing the remaining queens

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 09/21/2009.

### Page1 / 2

eightQueens - /= / Solves the 8 queens problem: place 8...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online