58bool isSafe(
const std::array<std::array<int, n>, n> &board,
const int &row,
63 for (i = 0; i < col; i++) {
70 for (i = row, j = col; i >= 0 && j >= 0; i--, j--) {
76 for (i = row, j = col; j >= 0 && i < n; i++, j--) {
91void solveNQ(std::array<std::array<int, n>, n> board,
const int &col) {
93 printSolution<n>(board);
99 for (
int i = 0; i < n; i++) {
102 if (isSafe<n>(board, i, col)) {
107 solveNQ<n>(board, col + 1);
122 std::array<std::array<int, n>, n> board = {
123 std::array<int, n>({0, 0, 0, 0}), std::array<int, n>({0, 0, 0, 0}),
124 std::array<int, n>({0, 0, 0, 0}), std::array<int, n>({0, 0, 0, 0})};
126 backtracking::n_queens::solveNQ<n>(board, 0);