📄 nqueenpuzzle.h
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -