nqueenpuzzle.h

来自「data+structures+using+c的源码」· C头文件 代码 · 共 39 行

H
39
字号


class nQueensPuzzle
{
public:
    nQueensPuzzle(int queens = 8);
 		//constructor
		//Postcondition: noOfSolutions = 0; noOfQueens = queens;
 		//               queensInRow is a pointer to the array 
		//               that store the n-tuple.
		//   If no value is specified for the parameter queens, 
		//   the default value, which is 8, is assigned to it.
    bool canPlaceQueen(int k, int i);
		//Function to determine whether a queen can be placed
 		//in row k and column i.
		//Postcondition: returns true if a queen can be placed in
		//   row k and column i; otherwise it returns false

    void queensConfiguration(int k); 
 		//Function to determine all solutions to the n-queens 
 		//puzzle using backtracking.
 		//The function is called with the value 0.
 		//Postcondition: All n-tuples representing solutions of
 		//   n-queens puzzle are generated and printed.

    void printConfiguration();
		//Function to output an n-tuple containing a solution
 		//to the n-queens puzzle.

    int solutionsCount();
		//Function to return the total number of solutions.
 		//Postcondition: The value of noOfSolution is returned.

private:
    int noOfSolutions;
    int noOfQueens;
    int *queensInRow;
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?