uses crt; label 88,1,2,3,4,5,6,7,8,999,997,998,20,21,22,23,24,25,26,27; var ar,q,l,k,ni,mm,nn,rr,jh,hj,n,lev,v,w,m,i,xx,yy,kk:integer; r,j,ho,col,fon,level,t,b,f,d,d1,d2,e,u,z,c,x,y:integer; A:array[1..10,1..10] of integer; rea,s,str,stroka :string; fff:text; procedure pole; var i,k:integer; begin clrscr; for xx:=1 to 10 do begin for yy:=1 to 10 do begin if ((xx+yy) mod 2)=0 then begin c:=(6); end else begin c:=(7); end; textbackground(c); if ((xx+yy) mod 2)<>0 then textcolor(brown) else textcolor(7); gotoxy(xx+14,yy+9); write(' '); end; end; textbackground(0); textcolor(7); gotoxy(15,9);write('0123456789'); for kk:=0 to 9 do begin gotoxy(14,kk+10); writeln(kk); end; end; procedure check; label 5; begin for c:=1 to 2 do begin for t:=1 to 10 do begin for b:=1 to 10 do if A[t,b]=c then begin e:=0; f:=0; d1:=0; d2:=0; for d:=0 to 4 do begin if (A[t+d,b]=c) and (t<7) then e:=e+1; if (A[t,b+d]=c) and (b<7) then f:=f+1; if (A[t+d,b+d]=c) and (t<7) and (b<7) then d1:=d1+1; if (A[t+d,b-d]=c) and (t<7) and (b>4) then d2:=d2+1; end; if (e=5) or (f=5) or (d1=5) or (d2=5) then goto 5; end; end; end; 5:end; procedure zero; label 2,3,6; begin jh:=0; 2:xx:=random(9)+1; yy:=random(9)+1;jh:=jh+1; if jh>30 then goto 3; if A[xx,yy]<>0 then goto 2; A[xx,yy]:=3; goto 6; 3:begin for t:=1 to 10 do begin for b:=1 to 10 do begin if (m=0) and (A[t,b]=0) then begin A[t,b]:=3; m:=1; end; end; end; end; if m=0 then begin ni:=1; m:=1; end; 6:end; procedure com; var c,u,k,l:integer; begin for l:=1 to 10 do begin for k:=1 to 10 do if A[l,k]=3 then begin if ((l+k) mod 2)=0 then begin c:=brown; u:=(7); A[l,k]:=2; end else begin c:=(7); u:=brown; A[l,k]:=2; end; textcolor(u); textbackground(c); gotoxy(l+14,k+9); write('o'); end; end; end; procedure xyblink; label 5; begin m:=0; for c:=1 to 2 do begin for t:=1 to 10 do begin for b:=1 to 10 do if m=0 then if A[t,b]=c then begin e:=0; f:=0; d1:=0; d2:=0; begin for d:=0 to 4 do begin if A[t+d,b]=c then e:=e+1; if A[t,b+d]=c then f:=f+1; if A[t+d,b+d]=c then d1:=d1+1; if A[t+d,b-d]=c then d2:=d2+1; end; if (e=5) and (m=0) and (t in [1..6]) then while not keypressed do begin k:=t+14; l:=b+9; for u:=0 to 4 do begin if ((k+l+u) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k+u,l); if A[t,b]=1 then write('x'); if (A[t,b]=3) or (A[t,b]=2) then write('o'); end; delay(200); for u:=0 to 4 do begin if ((k+l+u) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k+u,l);write(' '); end; delay(200); m:=1; end; if (f=5) and (m=0) and (b in [1..6]) then while not keypressed do begin k:=t+14; l:=b+9; for u:=0 to 4 do begin if ((k+l+u) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k,l+u); if A[t,b]=1 then write('x'); if (A[t,b]=2) or (A[t,b]=3) then write('o'); end; delay(200); for u:=0 to 4 do begin if ((k+l+u) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k,l+u);write(' '); end; delay(200); m:=1; end; if (d1=5) and (m=0) and (b in [1..6]) and (t in [1..6]) then while not keypressed do begin k:=t+14; l:=b+9; for u:=0 to 4 do begin if ((k+l+2*u) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k+u,l+u); if A[t,b]=1 then write('x'); if (A[t,b]=2) or (A[t,b]=3) then write('o'); end; delay(200); for u:=0 to 4 do begin if ((k+l+2*u) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k+u,l+u);write(' '); end; delay(200); m:=1; end; if (d2=5) and (m=0) and (t in [1..6]) and (b in [5..10]) then while not keypressed do begin k:=t+14; l:=b+9; for u:=0 to 4 do begin if ((k+l+u*2) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k+u,l-u); if A[t,b]=1 then write('x'); if (A[t,b]=2) or (A[t,b]=3) then write('o'); end; delay(200); for u:=0 to 4 do begin if ((k+l+u*2) mod 2)=0 then begin c:=(7); col:=(6); end else begin c:=(6); col:=(7); end; textbackground(c); textcolor(col); gotoxy(k+u,l-u);write(' '); end; delay(200); m:=1; end; end; end; end; end; end; begin 8:textmode(co40); pole; textbackground(0); textcolor(7); x:=21; y:=20; gotoxy(15,20); write('Level:0123'); textbackground(1); textcolor(7); gotoxy(21,20); write('0'); gotoxy(21,20); repeat s:=readkey; textbackground(0); if x=21 then write('0'); if x=22 then write('1'); if x=23 then write('2'); if x=24 then write('3'); textbackground(1); if s=chr(0) then begin s:=readkey; if (s='K') then begin x:=x-1; if x<21 then x:=x+4; end; if (s='M') then begin x:=x+1; if x>24 then x:=x-4; end; gotoxy(x,y); if x=21 then write('0'); if x=22 then write('1'); if x=23 then write('2'); if x=24 then write('3'); textbackground(0); gotoxy(x,y); end; until (s=chr(13)) or (s=chr(27)); if s=chr(27) then goto 997; if x=21 then level:=0; if x=22 then level:=1; if x=23 then level:=2; if x=24 then level:=3; x:=15; y:=10; mm:=0; 1: for t:=1 to 10 do begin for b:=1 to 10 do begin if A[t,b]=0 then goto 999; end;end;mm:=1; goto 998; randomize; 999:textbackground(0); textcolor(7); gotoxy(15,20);write(' '); gotoxy(15,20); begin if (x=15) and (y=10) then begin textbackground(1); gotoxy(15, 10 ); if A[x-14,y-9]=1 then write('x'); if A[x-14,y-9]=2 then write('o'); if A[x-14,y-9]=0 then write(' '); gotoxy(15,21); textbackground(0); textcolor(0); end; 88: repeat s:=ReadKey; if s=chr(0) then begin s:=readkey; if (s='K') or (s='M') or (s='H') or (s='P') then begin gotoxy(x,y); begin if ((x+y) mod 2)<>0 then begin c:=brown; u:=(7); end else begin c:=(7); u:=brown; end; textcolor(u); textbackground(c); gotoxy(x,y); if A[x-14,y-9]=1 then write('x'); if (A[x-14,y-9]=2) or (A[x-14,y-9]=3) then write('o'); if A[x-14,y-9]=0 then write(' '); gotoxy(15,21); textbackground(0); textcolor(0); end; if (s='K') then begin x:=x-1; if x<15 then x:=x+10; end; if (s='M') then begin x:=x+1; if x>24 then x:=x-10; end; if (s='H') then begin y:=y-1; if y<10 then y:=y+10; end; if (s='P') then begin y:=y+1; if y>19 then y:=y-10; end; end; end; textcolor(white); begin textbackground(1); gotoxy(x, y ); if A[x-14,y-9]=1 then write('x'); if (A[x-14,y-9]=2) or (A[x-14,y-9]=3) then write('o'); if A[x-14,y-9]=0 then write(' '); gotoxy(15,21); textbackground(0); textcolor(0); end; until (s=chr(13)) or (s=chr(27)); if s=chr(27) then goto 997; if A[x-14,y-9]<>0 then goto 88; end; if (x<15) or (x>24) then goto 88; if (y<10) or (y>19) then goto 88; A[x-14,y-9]:=1; textcolor(7); textbackground(1); gotoxy(x,y); write('x'); m:=0; {if (level=2) or (level=3) then lev:=2 else lev:=1; if level=0 then zero;} if (level=3) or (level=2) then begin for v:=2 downto 1 do begin if v=2 then rr:=1 else rr:=2; for t:=1 to 10 do begin for b:=1 to 10 do if A[t,b]=v then if m=0 then begin e:=0; f:=0; d1:=0; d2:=0; for d:=0 to 4 do begin if A[t+d,b]=v then e:=e+1; if A[t,b+d]=v then f:=f+1; if A[t+d,b+d]=v then d1:=d1+1; if A[t+d,b-d]=v then d2:=d2+1; end; if e=4 then begin if t<7 then begin for c:=1 to 4 do begin if (m=0) and (A[t+c,b]=0) then begin A[t+c,b]:=3; m:=1; end; end;end; if (m=0) and (t in [2..7]) then if (A[t-1,b]=0) and ((A[t+4,b]=rr) or (A[t+4,b]=0)) then begin A[t-1,b]:=3; m:=1; end; end; if f=4 then begin if b<7 then begin for c:=1 to 4 do begin if (m=0) and (A[t,b+c]=0) then begin A[t,b+c]:=3; m:=1; end; end;end; if (m=0) and (b in [2..7]) then if (A[t,b-1]=0) and ((A[t,b+4]=rr) or (A[t,b+4]=0)) then begin A[t,b-1]:=3; m:=1; end; end; if d1=4 then begin if (b<7) and (t<7) then begin for c:=1 to 4 do begin if (m=0) and (A[t+c,b+c]=0) then begin A[t+c,b+c]:=3; m:=1; end; end;end; if (m=0) and (t in [2..7]) and (b in [2..7]) then if (A[t-1,b-1]=0) and ((A[t+4,b+4]=rr) or (A[t+4,b+4]=0)) then begin A[t-1,b-1]:=3; m:=1; end; end; if d2=4 then begin if (t<7) and (b>4) then begin for c:=1 to 4 do begin if (m=0) and (A[t+c,b-c]=0) then begin A[t+c,b-c]:=3; m:=1; end; end; end; if (m=0) and (t in [2..7]) and (b in [4..9]) then if (A[t-1,b+1]=0) and ((A[t+4,b-4]=rr) or (A[t+4,b+4]=0)) then begin A[t-1,b+1]:=3; m:=1; end; end; end; end; end; end; if level=3 then begin if m=0 then for v:=2 downto 1 do begin if v=2 then rr:=1 else rr:=2; for t:=1 to 10 do begin for b:=1 to 10 do if A[t,b]=v then if m=0 then begin e:=0; f:=0; d1:=0; d2:=0; for d:=0 to 3 do begin if A[t+d,b]=v then e:=e+1; if A[t,b+d]=v then f:=f+1; if A[t+d,b+d]=v then d1:=d1+1; if A[t+d,b-d]=v then d2:=d2+1; end; if (e=3) and (m=0) then begin if t in [2..6] then if (A[t+1,b]=0) or (A[t+2,b]=0) then if (A[t-1,b]=0) and (A[t+4,b]=0) then if A[t+1,b]=0 then begin A[t+1,b]:=3; m:=1; end else begin A[t+2,b]:=3; m:=1; end; end; if (f=3) and (m=0) then begin if b in [2..6] then if (A[t,b+1]=0) or (A[t,b+2]=0) then if (A[t,b-1]=0) and (A[t,b+4]=0) then if A[t,b+1]=0 then begin A[t,b+1]:=3; m:=1; end else begin A[t,b+2]:=3; m:=1; end; end; if (d1=3) and (m=0) then begin if (t<7) and (b<7) then if (A[t+1,b+1]=0) or (A[t+2,b+2]=0) then if (A[t-1,b-1]=0) and (A[t+4,b+4]=0) then if A[t+1,b+1]=0 then begin A[t+1,b+1]:=3; m:=1; end else begin A[t+2,b+2]:=3; m:=1; end; end; if (d2=3) and (m=0) then begin if (t<7) and (b>4) then if (A[t+1,b-1]=0) or (A[t+2,b-2]=0) then if (A[t-1,b+1]=0) and (A[t+4,b-4]=0) then if A[t+1,b-1]=0 then begin A[t+1,b-1]:=3; m:=1; end else begin A[t+2,b-2]:=3; m:=1; end; end; end; end; end; end; if level=3 then begin if m=0 then for v:=2 downto 1 do begin for q:=3 to 6 do begin for r:=2 to 9 do if A[q,r]=v then if m=0 then begin e:=0; f:=0; d1:=0; d2:=0; for d:=0 to 2 do begin if A[q+d,r]=v then e:=e+1; if A[q,r+d]=v then f:=f+1; if A[q+d,r+d]=v then d1:=d1+1; if A[q+d,r-d]=v then d2:=d2+1; end; begin if (e=3) and (m=0) then begin if (m=0) and (q in [3..6]) then if (A[q-1,r]=0) and (A[q+3,r]=0) then begin if (m=0) and (A[q-2,r]=0) then begin A[q-1,r]:=3; m:=1; end; if (m=0) and (A[q+4,r]=0) then begin A[q+3,r]:=3; m:=1; end; end; end; if (f=3) and (m=0) then begin if r in [3..6] then if (A[q,r-1]=0) and (A[q,r+3]=0) then begin if (m=0) and (A[q,r-2]=0) then begin A[q,r-1]:=3; m:=1; end; if (m=0) and (A[q,r+4]=0) then begin A[q,r+3]:=3; m:=1; end; end; end; if (d1=3) and (m=0) then begin if (q in [3..6]) and (r in [3..6]) then if (A[q-1,r-1]=0) and (A[q+3,r+3]=0) then begin if (m=0) and (A[q-2,r-2]=0) then begin A[q-1,r-1]:=3; m:=1; end; if (m=0) and (A[q+4,r+4]=0) then begin A[q+3,r+3]:=3; m:=1; end; end; if (m=0) and (q in [3..6]) and (r=2) then if (A[q-1,r-1]=0) and (A[q+3,r+3]=0) then if A[q+4,r+4]=0 then begin A[q+3,r+3]:=3; m:=1; end; if (m=0) and (q in [3..6]) and (r=7) then if (A[q-1,r-1]=0) and (A[q+3,r+3]=0) then if A[q-2,r-2]=0 then begin A[q-1,r-1]:=3; m:=1; end; end; if (d2=3) and (m=0) then begin if (q in [3..6]) and (r in [5..8]) then if (A[q-1,r+1]=0) and (A[q+3,r-3]=0) then begin if A[q-2,r+2]=0 then begin A[q-1,r+1]:=3; m:=1; end; if (m=0) and (A[q+4,r-4]=0) then begin A[q+3,r-3]:=3; m:=1; end; end; if (m=0) and (q in [3..6]) and (r=4) then if (A[q-1,r+1]=0) and (A[q+3,r-3]=0) then if A[q-2,r+2]=0 then begin A[q-1,r+1]:=3; m:=1; end; if (m=0) and (q in [3..6]) and (r=9) then if (A[q-1,r+1]=0) and (A[q+3,r-3]=0) then if A[q+4,r-4]=0 then begin A[q+3,r-3]:=3; m:=1; end; end; end; end; end; end; end; if level=3 then begin if m=0 then for v:=2 downto 1 do begin for t:=2 to 8 do begin for b:=2 to 8 do if A[t,b]=v then if m=0 then begin if (m=0) and (t in [2..5]) and (b in [2..7]) then if (A[t-1,b-1]=0) and (A[t+1,b+1]=v) and (A[t+2,b+2]=0) and (A[t+3,b+3]=0) then begin if (A[t+1,b+3]=0) and (A[t+5,b-1]=0) then if (A[t+4,b]=v) and (A[t+3,b+1]=v) then begin A[t+2,b+2]:=3; m:=1; end; if (m=0) and (A[t+1,b+2]=0) and (A[t+5,b+2]=0) then if (A[t+4,b+2]=v) and (A[t+3,b+2]=v) then begin A[t+2,b+2]:=3; m:=1; end; end; if (m=0) and (t in [3..6]) and (b in [3..8]) then if (A[t-2,b+2]=0) and (A[t-1,b+1]=v) and (A[t+1,b-1]=0) and (A[t+2,b-2]=0) then begin if (A[t+4,b+2]=0) and (A[t,b-2]=0) then if (A[t+2,b]=v) and (A[t+3,b+1]=v) then begin A[t+1,b-1]:=3; m:=1; end; if (m=0) and (A[t,b-1]=0) and (A[t+4,b-1]=0) then if (A[t+2,b-1]=v) and (A[t+3,b-1]=v) then begin A[t+1,b-1]:=3; m:=1; end; end; if (m=0) and (t in [3..8]) and (b in [3..6]) then if (A[t-2,b+2]=0) and (A[t+1,b-1]=v) and (A[t+2,b-2]=0) and (A[t-1,b+1]=0) then begin if (A[t-2,b]=0) and (A[t+2,b+4]=0) then if (A[t,b+2]=v) and (A[t+1,b+3]=v) then begin A[t-1,b+1]:=3; m:=1; end; if (m=0) and (A[t-1,b]=0) and (A[t-1,b+4]=0) then if (A[t-1,b+2]=v) and (A[t-1,b+3]=v) then begin A[t-1,b+1]:=3; m:=1; end; end; if (m=0) and (t in [2..7]) and (b in [2..5]) then if (A[t-1,b-1]=0) and (A[t+1,b+1]=v) and (A[t+2,b+2]=0) and (A[t+3,b+3]=0) then begin if (A[t+3,b+1]=0) and (A[t-1,b+5]=0) then if (A[t,b+4]=v) and (A[t+1,b+3]=v) then begin A[t+2,b+2]:=3; m:=1; end; if (m=0) and (A[t+2,b+1]=0) and (A[t+2,b+5]=0) then if (A[t+2,b+3]=v) and (A[t+2,b+4]=v) then begin A[t+2,b+2]:=3; m:=1; end; end; end; end; end; end; if level=3 then begin if m=0 then for v:=2 downto 1 do begin for t:=2 to 9 do begin for b:=2 to 9 do if A[t,b]=v then if m=0 then begin if (m=0) and (t in [4..9]) and (b in [2..6]) then if (A[t,b-1]=0) and (A[t,b+1]=0) and (A[t,b+2]=0) then if (A[t,b+4]=0) and (A[t,b+3]=v) then begin if (A[t-1,b+2]=v) and (A[t-2,b+3]=v) then if (A[t+1,b]=0) and (A[t-3,b+4]=0) then begin A[t,b+1]:=3; m:=1; end; if (m=0) and (A[t-2,b]=v) and (A[t-1,b+1]=v) then if (A[t-3,b-1]=0) and (A[t+1,b+3]=0) then begin A[t,b+2]:=3; m:=1; end; end; if (m=0) and (t in [2..7]) and (b in [2..6]) then if (A[t,b-1]=0) and (A[t,b+1]=0) and (A[t,b+2]=0) then if (A[t,b+4]=0) and (A[t,b+3]=v) then begin if (A[t+1,b+2]=v) and (A[t+2,b+3]=v) then if (A[t-1,b]=0) and (A[t+3,b+4]=0) then begin A[t,b+1]:=3; m:=1; end; if (m=0) and (A[t+1,b+1]=v) and (A[t+2,b]=v) then if (A[t+3,b-1]=0) and (A[t-1,b+3]=0) then begin A[t,b+2]:=3; m:=1; end; end; if (m=0) and (t in [2..6]) and (b in [2..7]) then if (A[t-1,b]=0) and (A[t+1,b]=0) and (A[t+2,b]=0) then if (A[t+4,b]=0) and (A[t+3,b]=v) then begin if (A[t+1,b+1]=v) and (A[t,b+2]=v) then if (A[t-1,b+3]=0) and (A[t+3,b-1]=0) then begin A[t+2,b]:=3; m:=1; end; if (m=0) and (A[t+2,b+1]=v) and (A[t+3,b+2]=v) then if (A[t,b-1]=0) and (A[t+4,b+3]=0) then begin A[t+1,b]:=3; m:=1; end; end; if (m=0) and (t in [2..6]) and (b in [4..9]) then if (A[t-1,b]=0) and (A[t+1,b]=0) and (A[t+2,b]=0) then if (A[t+4,b]=0) and (A[t+3,b]=v) then begin if (A[t,b-2]=v) and (A[t+1,b-1]=v) then if (A[t-1,b-3]=0) and (A[t+3,b+1]=0) then begin A[t+2,b]:=3; m:=1; end; if (m=0) and (A[t+2,b-1]=v) and (A[t+3,b-2]=v) then if (A[t,b-1]=0) and (A[t+4,b-3]=0) then begin A[t+1,b]:=3; m:=1; end; end; end; end; end; end; if (level=3) or (level=2) or (level=1) then begin if m=0 then for v:=2 downto 1 do begin for t:=1 to 10 do begin for b:=1 to 10 do if A[t,b]=v then if m=0 then begin e:=0; f:=0; d1:=0; d2:=0; for d:=0 to 2 do begin if A[t+d,b]=v then e:=e+1; if A[t,b+d]=v then f:=f+1; if A[t+d,b+d]=v then d1:=d1+1; if A[t+d,b-d]=v then d2:=d2+1; end; if (e=3) and (m=0) then begin if t in [3..6] then begin if (m=0) and (A[t-1,b]=0) and (A[t-2,b]=0) then begin A[t-1,b]:=3; m:=1; end; if (m=0) and (A[t+3,b]=0) and (A[t+4,b]=0) then begin A[t+3,b]:=3; m:=1; end; end; if t<3 then if (m=0) and (A[t+3,b]=0) and (A[t+4,b]=0) then begin A[t+3,b]:=3; m:=1; end; if t in [7..8] then if (m=0) and (A[t-1,b]=0) and (A[t-2,b]=0) then begin A[t-1,b]:=3; m:=1; end; end; if (f=3) and (m=0) then begin if b in [3..6] then begin if (m=0) and (A[t,b-1]=0) and (A[t,b-2]=0) then begin A[t,b-1]:=3; m:=1; end; if (m=0) and (A[t,b+3]=0) and (A[t,b+4]=0) then begin A[t,b+3]:=3; m:=1; end; end; if b<3 then if (m=0) and (A[t,b+3]=0) and (A[t,b+4]=0) then begin A[t,b+3]:=3; m:=1; end; if b in [7..8] then if (m=0) and (A[t,b-1]=0) and (A[t,b-2]=0) then begin A[t,b-1]:=3; m:=1; end; end; if (d1=3) and (m=0) then begin if (t in [3..6]) and (b in [3..6]) then begin if (m=0) and (A[t-1,b-1]=0) and (A[t-2,b-2]=0) then begin A[t-1,b-1]:=3; m:=1; end; if (m=0) and (A[t+3,b+3]=0) and (A[t+4,b+4]=0) then begin A[t+3,b+3]:=3; m:=1; end; end; if (t<3) and (b<7) then if (m=0) and (A[t+3,b+3]=0) and (A[t+4,b+4]=0) then begin A[t+3,b+3]:=3; m:=1; end; if (t in [7..8]) and (b in [3..8]) then if (m=0) and (A[t-1,b-1]=0) and (A[t-2,b-2]=0) then begin A[t-1,b-1]:=3; m:=1; end; end; if (d2=3) and (m=0) then begin if (t in [3..6]) and (b in [5..8]) then begin if (A[t-1,b+1]=0) and (A[t-2,b+2]=0) then begin A[t-1,b+1]:=3; m:=1; end; if (m=0) and (A[t+3,b-3]=0) and (a[t+4,b+4]=0) then begin A[t+3,b-3]:=3; m:=1; end; end; if (t<3) and (b>4) then if (m=0) and (A[t+3,b-3]=0) and (A[t+4,b-4]=0) then begin A[t+3,b-3]:=3; m:=1; end; if (t in [7..8]) and (b in [3..8]) then if (m=0) and (A[t-1,b+1]=0) and (A[t-2,b+2]=0) then begin A[t-1,b+1]:=3; m:=1; end; end; end; end; end; end; if (m=0) and ((level=2) or (level=3)) then begin for v:=2 downto 1 do begin for t:=1 to 10 do begin for b:=1 to 10 do begin if A[t,b]=v then begin if (m=0) and (t in [3..6]) and (A[t+2,b]=v) and (A[t+1,b]=0) then if (A[t-1,b]=0) and (A[t+3,b]=0) then begin A[t+1,b]:=3; m:=1; end; if (m=0) and (t in [3..6]) and (b in [3..6]) and (A[t+2,b+2]=v) and (A[t+1,b+1]=0) then if (A[t-1,b-1]=0) and (A[t+3,b+3]=0) then begin A[t+1,b+1]:=3; m:=1; end; if (m=0) and (t in [5..8]) and (b in [3..6]) and (A[t-2,b+2]=v) and (A[t-1,b+1]=0) then if (A[t+1,b-1]=0) and (A[t-3,b+3]=0) then begin A[t-1,b+1]:=3; m:=1; end; if (m=0) and (b in [3..6]) and (A[t,b+2]=v) and (A[t,b+1]=0) then if (A[t,b-1]=0) and (A[t,b+3]=0) then begin A[t,b+1]:=3; m:=1; end; end; end; end; end; end; if (level=3) or (level=2) or (level=1) then begin if m=0 then for v:=2 downto 1 do begin for t:=1 to 10 do begin for b:=1 to 10 do if A[t,b]=v then if m=0 then begin e:=0; f:=0; d1:=0; d2:=0; for d:=0 to 1 do begin if A[t+d,b]=v then e:=e+1; if A[t,b+d]=v then f:=f+1; if A[t+d,b+d]=v then d1:=d1+1; if A[t+d,b-d]=v then d2:=d2+1; end; begin if (e=2) and (m=0) then if t in [3..6] then if (A[t-1,b]=0) and (A[t+2,b]=0) then begin if (m=0) and (A[t-2,b]=0) then begin A[t-1,b]:=3; m:=1; end; if (m=0) and (A[t+3,b]=0) then begin A[t+2,b]:=3; m:=1; end; end; if (f=2) and (m=0) then if b in [3..6] then if (A[t,b-1]=0) and (A[t,b+2]=0) then begin if (m=0) and (A[t,b-2]=0) then begin A[t,b-1]:=3; m:=1; end; if (m=0) and (A[t,b+3]=0) then begin A[t,b+2]:=3; m:=1; end; end; if (d1=2) and (m=0) then if (t in [3..6]) and (b in [3..6]) then if (A[t-1,b-1]=0) and (A[t+2,b+2]=0) then begin if (m=0) and (A[t-2,b-2]=0) then begin A[t-1,b-1]:=3; m:=1; end; if (m=0) and (A[t+3,b+3]=0) then begin A[t+2,b+2]:=3; m:=1; end; end; if (d2=2) and (m=0) then if (t in [3..6]) and (b in [5..8]) then if (A[t-1,b+1]=0) and (A[t+2,b-2]=0) then begin if (A[t-2,b+2]=0) then begin A[t-1,b+1]:=3; m:=1; end; if (m=0) and (A[t+3,b-3]=0) then begin A[t+2,b-2]:=3; m:=1; end; end; end; end; end; end; end; if (level=3) or (level=2) or (level=1) then begin if m=0 then for v:=2 downto 1 do begin for t:=1 to 10 do begin for b:=1 to 10 do if A[t,b]=v then if m=0 then begin e:=0; f:=0; d1:=0; d2:=0; for d:=0 to 1 do begin if A[t+d,b]=v then e:=e+1; if A[t,b+d]=v then f:=f+1; if A[t+d,b+d]=v then d1:=d1+1; if A[t+d,b-d]=v then d2:=d2+1; end; if (e=2) and (m=0) then begin if t in [4..6] then begin if (m=0) and (A[t-1,b]=0) and (A[t-2,b]=0) then begin A[t-1,b]:=3; m:=1; end; if (m=0) and (A[t+2,b]=0) and (A[t+3,b]=0) then begin A[t+2,b]:=3; m:=1; end; end; if t<4 then if (m=0) and (A[t+2,b]=0) then begin A[t+2,b]:=3; m:=1; end; if t in [7..9] then if (m=0) and (A[t-1,b]=0) then begin A[t-1,b]:=3; m:=1; end; end; if (f=3) and (m=0) then begin if b in [4..6] then begin if (m=0) and (A[t,b-1]=0) and (A[t,b-2]=0) then begin A[t,b-1]:=3; m:=1; end; if (m=0) and (A[t,b+2]=0) and (A[t,b+3]=0) then begin A[t,b+2]:=3; m:=1; end; end; if b<4 then if (m=0) and (A[t,b+2]=0) then begin A[t,b+2]:=3; m:=1; end; if b in [7..9] then if (m=0) and (A[t,b-1]=0) then begin A[t,b-1]:=3; m:=1; end; end; if (d1=3) and (m=0) then begin if (t in [4..6]) and (b in [4..6]) then begin if (m=0) and (A[t-1,b-1]=0) and (A[t-2,b-2]=0) then begin A[t-1,b-1]:=3; m:=1; end; if (m=0) and (A[t+2,b+2]=0) and (A[t+3,b+3]=0) then begin A[t+2,b+2]:=3; m:=1; end; end; if (t<4) and (b<7) then if (m=0) and (A[t+2,b+2]=0) then begin A[t+2,b+2]:=3; m:=1; end; if (t in [7..9]) and (b in [3..9]) then if (m=0) and (A[t-1,b-1]=0) then begin A[t-1,b-1]:=3; m:=1; end; end; if (d2=2) and (m=0) then begin if (t in [4..6]) and (b in [5..7]) then begin if (A[t-1,b+1]=0) and (A[t-2,b+2]=0) then begin A[t-1,b+1]:=3; m:=1; end; if (m=0) and (A[t+2,b-2]=0) and (A[t+3,b-3]=0) then begin A[t+2,b-2]:=3; m:=1; end; end; if (t<4) and (b>4) then if (m=0) and (A[t+2,b-2]=0) then begin A[t+2,b-2]:=3; m:=1; end; if (t in [7..9]) and (b in [2..6]) then if (m=0) and (A[t-1,b+1]=0) then begin A[t-1,b+1]:=3; m:=1; end; end; end; end; end; end; if (level=3) or (level=2) or (level=1) then begin if m=0 then for v:=2 downto 1 do begin for t:=3 to 8 do begin for b:=3 to 8 do if A[t,b]=v then if m=0 then begin randomize; hj:=random(7)+20; if hj=20 then goto 20; if hj=21 then goto 21; if hj=22 then goto 22; if hj=23 then goto 23; if hj=24 then goto 24; if hj=25 then goto 25; if hj=26 then goto 26; if hj=27 then goto 27; 20:if (m=0) and (A[t-1,b]=0) then begin A[t-1,b]:=3; m:=1; end; 21:if (m=0) and (A[t+1,b-1]=0) then begin A[t+1,b-1]:=3; m:=1; end; 22:if (m=0) and (A[t,b-1]=0) then begin A[t,b-1]:=3; m:=1; end; 23:if (m=0) and (A[t-1,b-1]=0) then begin A[t-1,b-1]:=3; m:=1; end; 24:if (m=0) and (A[t+1,b]=0) then begin A[t+1,b]:=3; m:=1; end; 25:if (m=0) and (A[t,b+1]=0) then begin A[t,b+1]:=3; m:=1; end; 26:if (m=0) and (A[t-1,b+1]=0) then begin A[t-1,b+1]:=3; m:=1; end; 27:if (m=0) and (A[t+1,b+1]=0) then begin A[t+1,b+1]:=3; m:=1; end; end; end; end; end; if m=0 then zero; com; check; if (e=5) or (f=5) or (d1=5) or (d2=5) then goto 3; if s=chr(27) then goto 997; goto 1; 3:textbackground(0); textcolor(7); gotoxy(15,20); if c=1 then begin write(' You won!'); 998: gotoxy(15,21); textbackground(0); textcolor(7); write('Game over!'); xyblink; if mm=1 then begin readln end; goto 997; end else begin writeln(' I won!'); gotoxy(15,21); textbackground(0); write('Game over!'); xyblink; textmode(co80); assign(fff,'history.txt'); reset(fff); while not EOF(fff) do begin readln(fff,stroka); writeln(stroka); end; close(fff); begin sound(349);delay(500);sound(467);delay(750);sound(440);delay(250);sound(523);delay(250);sound(467);delay(250);sound(349); delay(250);sound(294);delay(250);sound(392);delay(1000);sound(311);delay(500);nosound;delay(200);sound(392);delay(250); sound(523);delay(750);nosound;delay(40);sound(467);delay(250);sound(440);delay(250);sound(392);delay(250);sound(349); delay(250);sound(311);delay(250);sound(294);delay(1000);nosound;delay(80);sound(349);delay(500);sound(467);delay(750); sound(440);delay(250);sound(523);delay(250);sound(467);delay(250);sound(349);delay(250);sound(294);delay(250);sound(392); delay(1000);sound(311);delay(250);sound(392);delay(250);sound(523);delay(250);sound(467);delay(250);sound(440);delay(500); sound(523);delay(500);sound(622);delay(500);sound(440);delay(500);sound(467);delay(1000);sound(467);delay(250);nosound; delay(500);nosound; end; 997:end;textmode(lastmode);4:end.