procedure TForm1.BackTracking(k:integer;a:ta);
var i,j,o:integer;
Stack: array[1..8] of Integer;
po:boolean;
b:ta;
begin
if exitclick then exit;
repeat
if (K<Curlen) then
Begin
for i:=1 to curlen do
b[i]:=Stack[i];
for i:=1 to curlen do
Begin
po:=true;
for j:=1 to k do
Begin
if Stack[j]=i then
po:=false;
if abs(Stack[j]-i)=abs(j-k-1) then
po:=false
End;
if po then
Begin
b[k+1]:=i;
Stack[o]:=b[k+1];
inc(k);
BackTracking(k+1,b);
End;
End;
End
else
Begin
Inc(Co);
Form1.Caption:=IntToStr(co);
Form1.Draw(a);
t:=GetTickCount;
repeat
Application.ProcessMessages;
until (GetTickCount-t)>showtime;
DrawGrid1.Repaint;
End;
inc(o);
Until o>curlen
End;