program labirint; uses crt; var labx,laby,curx,cury,oldx,oldy,lx,ly,flg:integer; lab:array[1..10,1..10] of char; vopr:string; procedure loadlab; var labstr:array[1..10] of string;tmp:string; x,y:integer; begin labstr[1]:='ÚÄÄÄÄÄÄÄÄ¿'; labstr[2]:='³ * ³'; labstr[3]:='³ ÄÄÄ¿ ³'; labstr[4]:='³ ³ ³'; labstr[5]:='ÃÄÄ Ä´ ³'; labstr[6]:='³ ³ ³'; labstr[7]:='ÃÄ¿ ÀÄÄÄ´'; labstr[8]:='³ ³ ³'; labstr[9]:=' ³ ³'; labstr[10]:='ÀÄÄÄÄÄÁÄÄÙ'; for y:=1 to 10 do begin tmp:=labstr[y]; for x:=1 to 10 do begin if tmp[x]='*' then begin lx:=x; ly:=y; lab[x,y]:=' '; end; if tmp[x]<>'*' then lab[x,y]:=tmp[x]; end; end; end; procedure move(dx,dy:integer); begin gotoxy(1,1); writeln(curx,' ',cury); oldx:=curx; oldy:=cury; curx:=curx+dx; cury:=cury+dy; if (oldx>0) and (oldy>0) then begin gotoxy(oldx+labx,oldy+laby); textcolor(0); writeln('*'); end; gotoxy(labx+curx,laby+cury); textcolor(12); writeln('*'); end; procedure drawlab; var x,y:integer; begin clrscr; textcolor(14); oldx:=0;oldy:=0; for x:=1 to 10 do begin for y:=1 to 10 do begin gotoxy(x+labx,y+laby); write(lab[x,y]); end; end; move(0,0); end; function checkmove:integer; var key:char; exitcode,nx,ny:integer; begin checkmove:=0;exitcode:=0; while exitcode=0 do begin if keypressed then begin; key:=readkey; if key='*' then exitcode:=1;checkmove:=1; if key='4' then labx:=labx-1; if key='6' then labx:=labx+1; if key='2' then laby:=laby+1; if key='8' then laby:=laby-1; if (key='2') or (key='4') or (key='6') or (key='8') then drawlab; if key=#0 then begin key:=readkey; if (key='H') and (lab[curx,cury-1]=' ') then move(0,-1); if (key='K') and (lab[curx-1,cury]=' ') then move(-1,0); if (key='M') and (lab[curx+1,cury]=' ') then move(1,0); if (key='P') and (lab[curx,cury+1]=' ') then move(0,1); end; end; if (curx=1) or (curx=10) or (cury=1) or (cury=10) then begin exitcode:=2; checkmove:=2; end; end; end; begin labx:=10;laby:=10; loadlab; repeat curx:=lx;cury:=ly;flg:=0; drawlab; while flg=0 do flg:=checkmove; textcolor(10); gotoxy(20,1); if flg=1 then write('ˆ£à  ¯à¥à¢ ­ . '); if flg=2 then write('‚ë ¢ë¨£à «¨!!! '); write ('த®«¦¨âì? '); readln(vopr); until (vopr<>'y') and (vopr<>'Y'); end.