Program Cross; { Crosswords } Var a: array[1..100,1..100] of char; i,j: byte; { For max 255 length crosswords only. See Procedure Compare to modify. } Procedure Put(s: string; x,y: byte; d: string); Begin If d='d' then For i:=y to y+length(s)-1 do a[x,i]:=s[i-y+1]; If d='u' then for i:=y downto y-length(s)+1 do a[x,i]:=s[-i+y+1]; If d='r' then For i:=x to x+length(s)-1 do a[i,y]:=s[i-x+1]; If d='l' then For i:=x to x-length(s)+1 do a[i,y]:=s[-i+x+1]; End; Procedure WriteCross; Begin for i:=1 to 20 do begin for j:=1 to 20 do Write(a[j,i]); WriteLn; End; End; Function Compare: boolean; Var f: text; x,y,q: integer; s: string; o: boolean; Begin o:=true; Assign(f,'cross2.inp'); Reset(f); ReadLn(f,s); Val(s,x,q); ReadLn(f,s); Val(s,y,q); ReadLn(f,s); i:=1; j:=1; q:=1; While q<=length(s) do begin If s[q]<>a[j,i] then o:=false; Inc(q); Inc(j); If j=x+1 then begin j:=1; i:=i+1; end; End; Compare:=o; Close(f); End; Procedure Clear; Begin For i:=1 to 100 do For j:=1 to 100 do a[i,j]:=' '; End; Procedure Load; Var f: text; c: byte; x,y,q: integer; s,t,u,v,w: string; Begin Assign(f,'cross1.inp'); Reset(f); While not eof(f) do begin ReadLn(f,s); c:=pos(' ',s); t:=Copy(s,1,c-1); s:=Copy(s,c+1,255); c:=pos(' ',s); u:=Copy(s,1,c-1); s:=Copy(s,c+1,255); c:=pos(' ',s); v:=Copy(s,1,c-1); w:=Copy(s,c+1,1); Val(u,x,q); Val(v,y,q); Put(t,x,y,w); End; Close(f); If Compare then WriteLn('The crossword is correct.') else WriteLn('The crossword is incorrect.'); End; Begin Clear; Load; End.