Код
while j<>length(stroka) do {может здесь исправить length(stroka)+4}
begin
if copy(stroka,j,4)='word' then
begin
k:=k+1;
j:=j+4 {конечно,можно было бы и без этого, но тогда придется обрабатывать ненужные символы}
end
function GetCount(const s: String): Integer;
var
temp: String;
count: Integer;
begin
temp := s;
count := 0;
while (pos('word', temp) <> 0) do begin
delete(temp, pos('word', temp), 4);
inc(count);
end;
GetCount := count;
end;
function GetCount(const s: String): Integer;
var
i, count: Integer;
begin
i := 1;
count := 0;
while (i <= length(s)) do begin
if Copy(s, i, 4) = 'word' then begin
inc(count);
inc(i, 4);
end
else inc(i);
end;
GetCount := count;
end;
function GetCount(s: String): Integer;
var
p, count: Integer;
begin
count := 0;
repeat
p := pos('word', s);
if p <> 0 then begin
delete(s, p, 4);
inc(count);
end;
until p = 0;
GetCount := count;
end;