![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Eight Queens puzzle, printing all solutions More...
#include <array>#include <iostream>Go to the source code of this file.
Namespaces | |
| namespace | backtracking |
| for vector container | |
| namespace | n_queens_all_solutions |
| Functions for the Eight Queens puzzle with all solutions. | |
Functions | |
| template<size_t n> | |
| void | backtracking::n_queens_all_solutions::PrintSol (const std::array< std::array< int, n >, n > &board) |
| Utility function to print matrix. | |
| template<size_t n> | |
| bool | backtracking::n_queens_all_solutions::CanIMove (const std::array< std::array< int, n >, n > &board, int row, int col) |
| Check if a queen can be placed on the matrix. | |
| template<size_t n> | |
| void | backtracking::n_queens_all_solutions::NQueenSol (std::array< std::array< int, n >, n > board, int col) |
| Main function to solve the N Queens problem. | |
| int | main () |
| Main function. | |
Eight Queens puzzle, printing all solutions
Definition in file nqueen_print_all_solutions.cpp.
| bool backtracking::n_queens_all_solutions::CanIMove | ( | const std::array< std::array< int, n >, n > & | board, |
| int | row, | ||
| int | col ) |
Check if a queen can be placed on the matrix.
| n | number of matrix size |
| board | matrix where numbers are saved |
| row | current index in rows |
| col | current index in columns |
check in the row
check the first diagonal
check the second diagonal
Definition at line 51 of file nqueen_print_all_solutions.cpp.
| int main | ( | void | ) |
Main function.
Definition at line 101 of file nqueen_print_all_solutions.cpp.
| void backtracking::n_queens_all_solutions::NQueenSol | ( | std::array< std::array< int, n >, n > | board, |
| int | col ) |
Main function to solve the N Queens problem.
| n | number of matrix size |
| board | matrix where numbers are saved |
| col | current index in columns |
Definition at line 81 of file nqueen_print_all_solutions.cpp.
| void backtracking::n_queens_all_solutions::PrintSol | ( | const std::array< std::array< int, n >, n > & | board | ) |
Utility function to print matrix.
| n | number of matrix size |
| board | matrix where numbers are saved |
Definition at line 31 of file nqueen_print_all_solutions.cpp.