Эта позиция не сводится
gotoxy(x0,y0+2);
write('|-+-+-|');
gotoxy(x0,y0+3);
write('!',s[4],'|',s[5],'|',s[6],'| ');
gotoxy(x0,y0+4);
write('+-+-+-+');
x0:=x0+10;
if(x0=81)then begin y0:=y0+5;
x0:=l;
end;
end;
procedure poisk;
var
q:integer;
label m; begin
for q:=0 to nmax-1 do
if pos0=tree[q] then goto m;
write(' Эта позиция не сводится к требуемой');
readln;
exit;
m:
print_tab(tree[q]};
q:=ind[q];
if q>=0 then goto m;
end;
procedure change(il,jl:integer);
var
tmp:char;
str2:string[6];
n,kl:integer; begin
if (i1<0)or (i1>l)or(j1<0)or(j1>2) then exit;
kl:=il*3+jl+l;
str2 : =tree.[ from] ;
tmp:=str2[k] ;
str2[k]:=str2[kl];
str2[kl]:=tmp;
for n:=0 to nmax-1 do
if str2=tree[n] then exit;
ind[nmax]:=from;
tree[nmax]:=str2;
inc(nmax); end;
procedure level; begin
for k:=l to 6 do
if tree[from] [k] = '*' then break;
i:=(k-l) div 3; {номер строки}
j:=(k-l) mod 3; {номер столбца}
change(i-1,j};
change(i+1,j);
change(i,j-1);
change(i,j+1);
end;
begin
nmax:=l;
x0:=l; y0:=2;
tree[0]:='BASIC*';
ind[0]:=-1;
clrscr;
write('Введите строку с исходной позицией');
read(pos0);
for from:=0 to 359 do level;
poisk;
readln;
end.
Содержание Назад