So, what isn't the problem? Anyway, in attempts to solve the N Queens problem using stacks library, we were met with issues trying to set function parameters to take our matrix and manipulate it.
int main(){
const int n = 8;
bool board[n][n];
Here we're trying to take in the board.
bool isValid(int n, bool board[][], int row, int col)
How else could we input our matrix?
We tried using Vectors and it screwed with our calculations, ruining our progress. We are currently trying to use dynamic arrays and pointers, but we don't understand the concept to be implemented in our scope.
One problem is the argument declaration
bool board[][], which is equal tobool (*board)[]. And C++ doesn't allow arrays without a size, the size needs to be specified by a compile-time constant.It might be possible to use
std::arrayand templates, perhaps aswhere
std::array<std::array<bool, N>, M> boardcorresponds tobool board[M][N].Note that
nis no longer needed as the size is built into the arrays themselves.Or use a global
constexprvariable initialized to the actual size, and use that for the array sizes instead of template values.