组件设置
paintbox绘图板显示当前的合法布局
Label文字标签显示当前合法布局的序号
Buttonbuttonbuttonbutton开始单幅连续退出按纽
程序清单
()代码单元unit
procedure TFormButtonClick(Sender: TObject);
begin
dstep:=true;
bhh:=tbhhcreate(false);
buttonenabled:=false;
buttonenabled:=true;
buttonenabled:=true;
end;
procedure TFormButtonClick(Sender: TObject);
begin
if dstep=false then begin bhhsuspend; dstep:=true end
else bhhresume
end;
procedure TFormButtonClick(Sender: TObject);
begin
dstep:=false; bhhresume;
end;
()代码单元unit
uses unit;
procedure TbhhExecute;
begin
hsu();
formbuttonenabled:=true;
formbuttonenabled:=false;
formbuttonenabled:=false;
end;
procedure tbhhprt;//显示
var ijixiy:integer;
s:real;iis:string[];
begin
str(tt:iis);
formlabelcaption:=第+iis+幅;
formpaintboxcanvasdraw(q);
for i:= to do
for j:= to do
if a[ij]= then
begin
ix:=(i)*+;
iy:=(j)*+;
formpaintboxcanvasdraw(iyixc);
end;
if dstep=true then suspend
else begin s:=; for i:= to do s:=s*s/s end;
end;
procedure tbhhhsu(i:integer);//回溯求解
var j:integer;
begin
if i> then begin tt:=tt+; synchronize(prt)end
else for j:= to do
begin a[ij]:=;if pd(ij) then hsu(i+);a[ij]:=;end
end;
constructor tbhhcreate(flag:boolean);//创建该线程的一实例并对有关的变量进行初始化
var ij:integer;
begin
inherited create(flag);
q:=tbitmapcreate;qloadfromfile(e:\八皇后\backingbmp);
c:=tbitmapcreate;cloadfromfile(e:\八皇后\queenbmp);
for i:= to do
for j:= to do
a[ij]:=; tt:=;
end;
end
[] []