// Using backtracking, this procedure prints all
//possible placements of n queens on an nXn
//chessboard so that they are nontracking.
{
for(i=1;i<=n;i++)
{
if(Place(k,i))then
{
x[k] = i;
if(k=n)then write(x[1:n]);
else NQueens(k+1, n);
}
}
}
//possible placements of n queens on an nXn
//chessboard so that they are nontracking.
{
for(i=1;i<=n;i++)
{
if(Place(k,i))then
{
x[k] = i;
if(k=n)then write(x[1:n]);
else NQueens(k+1, n);
}
}
}
No comments:
Post a Comment