diff --git a/backtracking/n_queens_all_solution_optimised.cpp b/backtracking/n_queens_all_solution_optimised.cpp index 40056100d..2c1e4a84a 100644 --- a/backtracking/n_queens_all_solution_optimised.cpp +++ b/backtracking/n_queens_all_solution_optimised.cpp @@ -1,27 +1,27 @@ #include #define n 4 -#define inc_loop(var, start, stop, step) for (int var=start; var <= stop; var+=step) -#define dec_loop(var, start, stop, step) for (int var=start; var >= stop; var-=step) +#define inc_loop(var, start, stop) for (int var=start; var <= stop; var++) +#define dec_loop(var, start, stop) for (int var=start; var >= stop; var--) void PrintSol(int Board[n][n]) { - inc_loop(i,0,n-1,1) { - inc_loop(j,0,n-1,1) + inc_loop(i,0,n-1) { + inc_loop(j,0,n-1) std::cout << Board[i][j] << " "; std::cout << std::endl; } std::cout << std::endl; - if (n%2==0 || (n%2==1 && Board[n/2+1][0]!=1)){ - inc_loop(i,0,n-1,1){ - dec_loop(j,n-1,0,1) - std::cout<