begin
window(40,1,60,2);
write(s);
readln; halt; end;
procedure show(k,с:integer) ;
const
pos:array [1..18] of byte = (3,2,7,2,11,2,3,4,7,4,11,4,3,6,7,6,11,6);
var
j:byte;
x,у:word;
begin
clrscr;
writeln (' +----+----+----+')
writeln('| | | |')
writeln (' |----|----|----| ')
writeln('| | | |')
writeln(' |----|-----|-----|')
writeln('| | | |')
write (' +----+----+----+')
a[k]:=c;
for j:=1 to 9 do begin
x:=pos[(j-l)*2+l]; y:=pos[(j-1)*2+2];
gotoxy(x,y);
if a[j]=+2 then write('X');
if a[j]=-2 then write('0');
end;
CurX:=7; CurY:=4; Ind:=5;
gotoxy(CurX,CurY); end;
function xod(k,kl:integer):boolean;
const
line:array [0..23] of byte=
(1, 2, 3,4, 5, б, 7, 8, 9,1,4, 7, 2, 5, 8, 3,6, 9,1,5, 9, 3,5,7) ;
var
j,m,p:byte; begin
xod:=false; for j:=0 to 7 do begin m:=j*3;
if a[line[m]]+a[line[m+1]]+a[line[m+2]]=2*k then begin
xod:=true;
for p:=m to m+2 do
if a[line[p]]=0 then
begin
show(line[p],kl);
exit;
end;
end;
end;
end;
procedure step345; begin
if xod( 2,2) then result('Победа компьютера');
if xod(-2,2) then exit;
for j :=1 to 9 do if a[j]=0 then begin
show(j,2);
break;
end;
end;
procedure input; const
Left=#75;
Right=#77;
Up=#72;
Down=#80;
Enter=#13; var
ch:char;
j,k:byte;
procedure cur_ind(var cur:word;porog,dcur,dind:integer) ;
begin
if cur <> porog then begin
cur:=cur+dcur;
Ind:=Ind+dind; end;
end; begin
k:=0;
for j:=l to 9 do
k:=k+abs(a[j]);
if k=18 then result('Боевая ничья');
ch:=readkey;
if ch=#0 then ch:=readkey;
case ch of
Left: cur_ind(CurX, 3,-4,-l);
Right: cur_ind(CurX,11, 4, 1);
Up: cur_ind(CurY, 2,-2,-3);
Down: cur_ind(CurY, 6, 2, 3);
Enter: if a[Ind]=0 then begin
show(Ind,-2);
exit;
end
else write(tt7);
else write(#7); end;
gotoxy(CurX,Cury);
input; end; begin
clrscr;
window(x0,y0,x0+13,y0+7);
show(5,2);
{ Первый ход программы }
input; { Ввод 1-го хода игрока }
for j:=1 to 9 do { Второй ход программы }
if a[j]=-2 then