uses crt; var a,d,fin,row,col,round,i,j : integer; cir : array [1..3,1..3] of integer; x : char; c,e : boolean; begin clrscr; round := 1; randomize; repeat for i := 1 to 3 do for j := 1 to 3 do cir[i,j]:=0; repeat fin :=0;e := true; for a := 1 to 3 do for d := 1 to 3 do if cir[a,d]=0 then e := false; if e then begin c := true; fin := 3; end else c := false; a := 1; if not c then if cir[1,1]+cir[2,2]+cir[3,3]=3 then fin := 1 else if cir[1,1]+cir[2,2]+cir[3,3]=-3 then fin :=-1 else if cir[1,3]+cir[2,2]+cir[3,1]=3 then fin :=1 else if cir[1,3]+cir[2,2]+cir[3,1]=-3 then fin := -1; if fin <> 0 then c := true; while (a<4)and not c do begin if cir[a,1]+cir[a,2]+cir[a,3]=3 then fin := 1 else if cir[a,1]+cir[a,2]+cir[a,3]=-3 then fin := -1 else if cir[1,a]+cir[2,a]+cir[3,a]=3 then fin :=1 else if cir[1,a]+cir[2,a]+cir[3,a]=-3 then fin := -1; a := a+1; end; if fin <> 0 then c := true; if not c then begin repeat write('Row: '); readln(row); write('Col: '); readln(col); until (row in [1,2,3]) and (col in [1,2,3])and (cir[row,col]=0); cir[row,col]:=-1; end; clrscr; if not c then begin repeat i := random(3)+1; j := random(3)+1; until cir[i,j]=0; cir[i,j]:=1; end; for i := 1 to 3 do begin for j := 1 to 3 do if cir[i,j]=1 then write('x') else if cir[i,j]=-1 then write('o') else write(' '); writeln end; until fin <> 0; if fin = 3 then writeln('Draw') else if fin = 1 then writeln('You Lose!!') else writeln('You win!!'); write('Again??'); readln(x); round := round +1; until x = 'n'; end.