<分区>
Possible Duplicate:
Dumb 8 Queens problem in C++
嗨 这个问题我过来了 **
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
}
}
如何检查对角线部分?还有如何枚举所有可能的情况?
提前致谢