eightQueens

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

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

View Full Document Right Arrow Icon
//================================================================== // 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
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online