Page 134 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 134
100 Problems & Solutions Trang 134
End;
Procedure Maydi;
Begin
Inc(dq);
if not ok then
Begin
If Q[dq].hg<dmay.hg then hgdi:=1
Else If Q[dq].hg>dmay.hg then hgdi:=-1
Else If Q[dq].cot<dmay.cot then hgdi:=-2
Else If Q[dq].cot>dmay.cot then hgdi:=2;
End;
dmay:=Q[dq];
A[q[dq].hg,q[dq].cot]:='x';
HienA(-10,10,-10,10)
End;
Procedure Process;
Var Hgc,p,i,ntt:Integer;
Begin
ok:=true; ntt:=0;
Ngdi;
Hgc:=Hgchan; Hgdi:=-Hgc;
Inc(cq); Nap(Q,dmay,hgdi,1); Maydi; Inc(dlt);
Repeat
Ngdi; Hgc:=Hgchan;
If ntt=1 then
If A[dc1.hg,dc1.cot]='.' then finish(dc1)
Else finish(dc2);
If ntt=0 then If (dlt>=3) and (kt(dc1,dc2)) then ntt:=1;
If (Hgc=Hgdi) then
If ok then
Begin
p:=2 div abs(Hgc);
For i:=1 to dlt-1 do
Begin
Inc(cq); Nap(Q,dmay,p,i); Nap(Qc,Q[cq],-hgdi,i);
Inc(cq); Nap(Q,dmay,-p,i);Nap(Qc,Q[cq],-hgdi,i);
End;
ok:=false;
dlt:=1;
End
Else
Begin
hgdi:=-hgdi; Inc(cq); Nap(Q,dmay,hgdi,dlt);
End;
If ntt=0 then
Begin
If dq=cq then Begin Inc(cq); Nap(Q,dmay,hgdi,1); End;
If A[Qc[dq].hg,Qc[dq].cot]='.' then finish(Qc[dq]);
Maydi; Inc(dlt);
End;
Tin học & Nhà trường 100 Đề Toán - Tin học