PROCEDURE KMPTEST(P : STRNG; M : INTEGER); VAR I,J : INTEGER ; BEGIN FLINK[1] :=0; I:=2 ; WHILE I<=M DO BEGIN J:=FLINK[I-1] ; WHILE (J<>0) AND (P[J]<>P[I-1]) DO J:=FLINK[J]; FLINK[I]:=J+1; I:=I+1; END; END; FUNCTION GETSTR (VAR S:STRNG):INTEGER ; VAR I:INTEGER ; BEGIN I:=1; WHILE (NOT EOF) AND (NOT EOLN) DO BEGIN READ (S[I]); I:=I+1; END; READ(S[I]); GETSTR:=I-1; END;