//dumb 8 queens using a 2-dimensional array to represent the board #include<cmat
ID: 3541947 • Letter: #
Question
//dumb 8 queens using a 2-dimensional array to represent the board
#include<cmath>
#include<iostream>
using namespace std;
bool ok( what goes here ){
and here
};
void print( what goes here ){
and here
};
int main( )
{ int board[8][8]={0};
int count = 0;
for(int i0 =0; i0 <8; i0 ++)
for(int i1 =0; i1 <8; i1 ++)
for(int i2 =0; i2 <8; i2 ++)
for(int i3 =0; i3 <8; i3 ++)
for(int i4 =0; i4 <8; i4 ++)
for(int i5 =0; i5 <8; i5 ++)
for(int i6 =0; i6 <8; i6 ++)
for(int i7 =0; i7 <8; i7 ++){
// use the indices of the loops to set a configuration in array board
// if this configuration is conflict-free, print the count and the board
if(ok(board)) print(board, ++count);
// reset the board for the next configuration
}
return 0;
}
please write the whole 8 queens programs in c++ and check horizontal, vertical and diagonal.
Explanation / Answer
#include #include #include #include using namespace std; char m[1000][1000]; int num,size,i,j,r,c,k,l,n; void initmat() { for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.