1 /* A program to solve the 8-queens problem */
6 type intArray = array of int
8 var row := intArray [ N ] of 0
9 var col := intArray [ N ] of 0
10 var diag1 := intArray [N+N-1] of 0
11 var diag2 := intArray [N+N-1] of 0
13 function printboard() = (
14 for i := 0 to N-1 do (
15 for j := 0 to N-1 do print(if col[i]=j then " O" else " .");
21 function try(c:int) = (
22 /* for i:= 0 to c do print("."); print("\n"); flush();*/
28 if row[r]=0 & diag1[r+c]=0 & diag2[r+7-c]=0