const
limits = [#0..#32,'.',',',':',';','!','?','"'];
type
TWords = array[1..40] of string;
var
text1 : string;
words : TWords;
DF : text;
temp,LOF : string;
W : string[20];
q : byte;
nomer,i : Integer;
function GetWords(s : string; var w : TWords) : byte;
var
i,back,n : byte;
begin
i := 1;
n := 0;
while(i<=length(s)) do
begin
while(i<=length(s)) and (s[i] in limits) do
inc(i);
if i<=length(s) then
begin
back := i;
while(i<=length(s)) and not(s[i] in limits) do
inc(i);
inc(n);
w[n] := copy(s, back, i-back);
end;
end;
GetWords := n;
end;
begin
Assign(DF,'DF.dat');
Reset(DF);
Writeln('Enter word:');
Readln(W);
temp:='';
While not EOF(DF) do
BEGIN
Readln(DF,LOF);
WriteLn(LOF);
temp:=temp+LOF;
end;
q:=GetWords(temp,words);
for i:=1 to q do
if w=words[i] then
nomer:=i;
writeln('Nomer vhidnogo slova ',w,' v text = ',nomer);
end.