```
#include <iostream>
using namespace std;
char chessboard[100][100] ={' '};
int n;
int savingposition[100][2]={ };
//checking rows....
bool checking (int row, int column){
for(int i = 0; i< n; i++){
for(int j = 0; j < n; j++) {
if((j+i== column+row|| column - row == j-i || i== row || j == column) && chessboard[i][j]=='Q')
return false;
}}
return true;
}
void displaytable()
{
for(int i = 0; i< n; i++){
for(int j = 0; j < n; j++) {
if (chessboard[i][j] != 'Q')
cout << '-';
else
cout << chessboard[i][j];
}
cout << endl;
}
for(int i = 0; i< n; i++){
for(int j = 0; j < 2; j++) {
//cout << savingposition[i][j];
}
cout << endl;
}
}
int main()
{
cout << "how many queens? enter from 1 to 1000-->";
cin >>n;
for(int row = 0; row < n; row++)
{
for(int column = 0; column <n; column++){
if( checking (row,column)){
chessboard[row][column] = 'Q';
savingposition[row][0] = row;
savingposition[row][1] = column; break;
if(row < n)
row = row+1;
column = 0;
}
else if(chessboard[row][column] != 'Q' && column == n ){
row = row-1;
column = savingposition[row][1];
chessboard[row][column] = '-';
if(column < n)
column = column+1;
}
}
displaytable();
}
return 0;
}
```

0