program hasonlitgat; {PM gyak - 2000.okt.17. - HBV} uses crt; var f:file of byte; minta:string; szoveg:string; elt:array [1..255] of integer; procedure velszam; var st:byte; procedure alapszovbe; var i:integer; begin assign(f,'file.txt'); rewrite(f); for i:=1 to 100 do begin randomize; st:=random(28)+65; write(f,st); end; close(f); end; procedure mintabe; var i:integer; m:string; begin for i:=1 to 4 do begin str(random(28+65),m); minta:=minta+m end; end; procedure eltolas(m:integer); {az eltolas erteket hatarozza meg} var i:integer; begin elt[i]:=1; for i:=(m-1) downto 1 do begin elt[i]:=elt[i+1]; while ( (i+elt[i]<=m) and (minta[i]<>minta[i+elt[i]]) ) do begin inc(elt[i]); end; end; end; procedure kiir; var i:integer; k:byte; begin for i:=1 to 100 do begin reset(f); read(f,k); write(chr(k)); write(elt[i]); delay(100); end; end; begin mintabe; alapszovbe; kiir; end; procedure keres1; {alap} var i:integer; {hol a szovegben} j:integer; {hol a mintaban} siker:boolean; begin i:=1; while (i<=length(szoveg)-length(minta)+1) and not(siker) do begin j:=1; while ( (minta[j]=szoveg[i+j-1]) and (length(minta)<>0 )) do begin inc(j); end; siker:=j>length(minta); if not siker then inc(i); end; end; procedure keres2; {Knuth} var i:integer; j:integer; siker:boolean; begin i:=1; siker:=false; while ( (i=length(szoveg)-length(minta)+1) and not siker ) do begin j:=length(minta); while ( (minta[j]=szoveg[i+j-1]) and (j>=1)) do begin dec(j); {itt kulonbozik az alaptol} end; siker:=(j=0); if not(siker) then i:=i+elt[j]; end; end; procedure keres3; {Bayer} begin end; procedure keres4; {szamrendszeres} begin end; begin velszam; readln; end.