var
a:array [1..100] of integer;
t,n,p:integer;
function find(k,i:integer):boolean;
var
j:integer;
yes:boolean;
begin
yes:=true;
for j:=1 to k-1 do
if (abs(a[j]-i)=abs(j-k)) or (i=a[j]) then yes:=false;
find:=yes;
end;
procedure print;
var
i:integer;
begin
p:=1;
for i:=1 to n do
write(a[i]:3);
writeln;
inc(t);
end;
procedure try(k:integer);
var
i:integer;
begin
if k>n then print
else
for i:=1 to n do
if find(k,i) then
begin
a[k]:=i;
try(k+1);
end;
if(p=0) and (k=1) and (a[k]=3) then
writeln('no solute!")
end;
begin
p:=0;t=0;
readln(n);
try(1);
writeln('Total=',t);
end.
八皇后问题的程序~那为大侠帮我转换一下谢谢~!!!