```
#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;
}
```

## Recommended Answers

Jump to PostIs there anything you need help with?

Jump to PostWhat's it do? Why did you post it? Are we supposed to be impressed or something?

Jump to Post

[boilerplate_help_info]

Posting requests for help must be well thought out if you want help quickly and correctly. Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful? Check your post with these checkpoints - what is ityou…

## All 10 Replies

neithan
1
Junior Poster in Training

WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague

mimah1
0
Newbie Poster

WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague

mimah1
0
Newbie Poster

TrustyTony
888
pyMod
Team Colleague
Featured Poster

mimah1
0
Newbie Poster

neithan
1
Junior Poster in Training

TrustyTony
888
pyMod
Team Colleague
Featured Poster

mimah1
0
Newbie Poster

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.