TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
N queens all optimized More...
#include <array>
#include <iostream>
Go to the source code of this file.
Namespaces | |
namespace | backtracking |
for vector container | |
namespace | n_queens_optimized |
Functions for Eight Queens puzzle optimized. | |
Functions | |
template<size_t n> | |
void | backtracking::n_queens_optimized::PrintSol (const std::array< std::array< int, n >, n > &board) |
template<size_t n> | |
bool | backtracking::n_queens_optimized::CanIMove (const std::array< std::array< int, n >, n > &board, int row, int col) |
template<size_t n> | |
void | backtracking::n_queens_optimized::NQueenSol (std::array< std::array< int, n >, n > board, int col) |
int | main () |
Main function. | |
N queens all optimized
Definition in file n_queens_all_solution_optimised.cpp.
bool backtracking::n_queens_optimized::CanIMove | ( | const std::array< std::array< int, n >, n > & | board, |
int | row, | ||
int | col ) |
Check if a queen can be placed on matrix
n | number of matrix size |
board | matrix where numbers are saved |
row | current index in rows |
col | current index in columns |
true
if queen can be placed on matrix false
if queen can't be placed on matrix check in the row
check the first diagonal
check the second diagonal
Definition at line 59 of file n_queens_all_solution_optimised.cpp.
int main | ( | void | ) |
Main function.
Definition at line 109 of file n_queens_all_solution_optimised.cpp.
void backtracking::n_queens_optimized::NQueenSol | ( | std::array< std::array< int, n >, n > | board, |
int | col ) |
Solve n queens problem
n | number of matrix size |
board | matrix where numbers are saved |
col | current index in columns |
Definition at line 89 of file n_queens_all_solution_optimised.cpp.
void backtracking::n_queens_optimized::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 30 of file n_queens_all_solution_optimised.cpp.