Page 148 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 148
100 Problems & Solutions Trang 148
best:=l[i,j,k];
mx:=i;my:=j;
end;
end;
end;
ok:=best<maxint;
end;
end;
procedure ghif;
var f :text;
k,kk :byte;
lap :string;
procedure viet(x,y:byte);
var u,v,s :byte;
begin
for s:=1 to 4 do
begin
u:=x+tx[s];
v:=y+ty[s];
if (u>0)and(v>0)and(u<=m)and(v<=n)and(l[u,v,k]=l[x,y,k]-1) then
begin
if l[u,v,k]>1 then viet(u,v);
write(f,h[5-s]);
break;
end;
end;
end;
begin
assign(f,fo);
rewrite(f);
if ok=false then write(f,'#')
else
begin
for k:=1 to 4 do
if (mx+tx[k]>0)and(my+ty[k]>0)and(mx+tx[k]<=m)and(my+ty[k]<=n) then
if (a[mx+tx[k],my+ty[k]]=0) then kk:=k;
lap:=h[kk]+h[5-kk];
for k:=1 to r do
begin
if l[mx,my,k]>1 then viet(mx,my);
for kk:=1 to (best-l[mx,my,k]) div 2 do write(f,lap);
writeln(f);
end;
end;
close(f);
end;
Tin học & Nhà trường 100 Đề Toán - Tin học