我自己编的,仅供参考program dd;var
i,he:longint;
a,b:array[1..8] of boolean;
c,d:array[-7..16] of boolean;procedure cou(h,o:longint; var y:longint);
var
l:longint;begin
for l:=1 to 8 do
if a[h] and b[l] and c[h+l] and d[h-l] then begin
a[h]:=false;
b[l]:=false;
c[h+l]:=false;
d[h-l]:=false;
if h>=8 then y:=y+1
else cou(h+1,l,y);
a[h]:=true;
b[l]:=true;
c[h+l]:=true;
d[h-l]:=true;
end;end;beginfor i:=1 to 8 dobegin
a:=true;
b:=true;end;for i:=-7 to 16 dobegin
c:=true;
d:=true;end;he:=0;cou(1,1,he);writeln(he);end. |