Hello all, I recently read up about the 8 queens problem and tried to solve it myself, in C++. I made a class called eq.h, an implementation file called eq.cpp, and a main.cpp.
The thing that I'm not sure about is, how do I check for row, column, and diagonal conflicts? What I'm thinking is, to use a nested for loop for conflict checking. How can that be applied? I've created a valid() function for that purpose. Below is what I've got so far.
#ifndef 8QUEEN_H
#define 8QUEEN_H
#include <iostream>
#include <algorithm>
usingnamespace std;
class 8queen
{
public:
8queen();
~8queen();
int solve();//solve problem using next_permutation
void display();
private:
bool valid();
int queens[8]; //array to store 8 integers that represent 8 queens
};
#endif