Possible Duplicate:
Dumb 8 Queens problem in C++
Hi I came over this question **
write an algorithm to print all ways of arranging 8 kings on the chess board so that none have same row,column ,diagonal
**
//initialize chess[i][j] to 0;
int king=100; //any other number except 0/1
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
//select any one position for the first column... lets start with j=0,i=0
if(chess[i][j]!=1)
chess[i][j]=king;
//now we should cross all rows with value i and column with value j
chess[i][]=1;
print(when chess[][]=king)
// we cannot enter king if chess[][]=1
}
}
how to check the diagonal part as well? also how to enumerate all the possible cases?
Thanks in adv..