The Tower of Babel

Pattern Matching Continued

One rendering in Pascal:

program Pattern_Matching(input,output)
var
  T: array [1..10000] of char;
  P: array [1..10000] of char;
  m, n, position : integer;
{ functions and procedures will go here }
begin
  readln(n, m)
  read_string(T,n); read_string(P,m);
  position := 1;
  repeat
    if occurs(P,m,T,position) then
      writeln(position);
    position := position+1
  until position > n-m+1
end.

read_string is a procedure and occurs is a function. These are defined next.

[TOC][Next]


CS1104 Main Page
Last Updated 01/05/2000
© L.Heath, 2000