Why I get WA? Pelase, help me!!!!!!! (+)
Program t1195;
Const May = 'XO#';
Var P : array[1..3,1..3]of Char;
i,j : integer;
Procedure WriteAns(S : String);
begin
Write(S);
Halt;
end;
Function CheckO(ch1,ch2,ch3 : Char) : boolean;
begin
CheckO:= (ch1='O')and(ch2='O')and(ch3='O');
end;
Function GetCheckO : boolean;
begin
GetCheckO :=
CheckO(p[1,1],p[1,2],p[1,3]) or
CheckO(p[2,1],p[2,2],p[2,3]) or
CheckO(p[3,1],p[3,2],p[3,3]) or
CheckO(p[1,1],p[2,1],p[3,1]) or
CheckO(p[1,2],p[2,2],p[3,2]) or
CheckO(p[1,3],p[2,3],p[3,3]) or
CheckO(p[1,1],p[2,2],p[3,3]) or
CheckO(p[1,3],p[2,2],p[3,1]);
end;
Function CheckX(ch1,ch2,ch3 : Char) : boolean;
begin
CheckX:= (ch1='X')and(ch2='X')and(ch3='X');
end;
Function GetCheckX : boolean;
begin
GetCheckX :=
CheckX(p[1,1],p[1,2],p[1,3]) or
CheckX(p[2,1],p[2,2],p[2,3]) or
CheckX(p[3,1],p[3,2],p[3,3]) or
CheckX(p[1,1],p[2,1],p[3,1]) or
CheckX(p[1,2],p[2,2],p[3,2]) or
CheckX(p[1,3],p[2,3],p[3,3]) or
CheckX(p[1,1],p[2,2],p[3,3]) or
CheckX(p[1,3],p[2,2],p[3,1]);
end;
Procedure Solve;
var i1,j1,i2,j2 : integer;
k : integer;
ans : array[1..3]of boolean;
ok : boolean;
begin
k:=0;
ok:=false;
for i1:=1 to 3 do for j1:=1 to 3 do if P[i1,j1]='#' then begin
P[i1,j1]:='X';
k:=k+1;
if GetCheckX then ok:=true;
ans[k]:=false;
for i2:=1 to 3 do for j2:=1 to 3 do if P[i2,j2]='#' then begin
P[i2,j2]:='O';
if GetCheckO then ans[k]:=true;
P[i2,j2]:='#';
end;
P[i1,j1]:='#';
end;
if ok then WriteAns('Crosses win');
if ans[1] and ans[2] and ans[3] then WriteAns('Ouths win');
WriteAns('Draw');
end;
begin
for i:=1 to 3 do
for j:=1 to 3 do begin
read(P[i,j]);
while Pos(P[i,j],May)=0 do read(P[i,j]);
end;
Solve;
end.