program tris;
uses sysutils, crt;
const nWhere=' NE NN NE WW CC EE SW SS SE';
var nw,nn,ne,ww,cc,ee,sw,ss,se,roba,x,y,where,whoT:string;who,xx:integer;
begin
writeln('Benvenuto! Come si chiama il PrimoGiocatore (Croce)?');readln(x);
writeln('Ed il secondo(cerchio)?');readln(y);
who:=1;
repeat;
clrscr;
writeln;writeln;
writeln(' ',nw,' | ',nn,' | ',ne);
writeln('----------------------------');
writeln(' ',ww,' | ',cc,' | ',ee);
writeln('----------------------------');
writeln(' ',sw,' | ',ss,' | ',se);
writeln;writeln;
who:=who+1;
if (who MOD 2)=0 then begin
whoT:=x;
roba:='X';
end
else begin
whoT:=y;
roba:='O';
end;
writeln('E il tuo turno, ',whoT,'!!');
writeln('Dove vuoi scrivere?');
writeln;
writeln(' nw | n | ne');
writeln('------------------------');
writeln(' w | c | e');
writeln('------------------------');
writeln(' sw | s | se');
writeln;
readln(where);
xx :=Pos( uppercase(where) + ' ', nWhere );
if xx>0 then begin
case xx of
1 : nw:=roba;
4 : nn:=roba;
7 : ne:=roba;
10 : ww:=roba;
13 : cc:=roba;
16 : ee:=roba;
19 : sw:=roba;
22 : ss:=roba;
25 : se:=roba;
end;
end;
until nw=(nn=ne) or ww=cc=ee or sw=ss=se or sw=cc=ne or nw=cc=se;
clrscr;
writeln;writeln;
writeln(' ',nw,' | ',nn,' | ',ne);
writeln('----------------------------');
writeln(' ',ww,' | ',cc,' | ',ee);
writeln('----------------------------');
writeln(' ',sw,' | ',ss,' | ',se);
writeln;writeln;
writeln('Complimenti!!! Ha vinto giocatore ',whoT);
readln;
end.