Определить количество повторений в тексте заданного слова. Считать, что слова в тексте отделены друг от друга одним пробелом — Pascal(Паскаль)

uses
  crt;
const
  dividers = [' ',',','.',';',':','-','=','+'];
var
  s,q,temp:string;
  i,c:integer;
begin
  ClrScr;
  ReadLn(s,q);
  temp:='';
  c:=0;
  if pos(q,s)<>0 then
    for i:=1 to Length(s) do
    begin
      if not (s[i] in dividers) then
        temp:=temp+s[i];
      if ((s[i] in dividers) or (i=Length(s))) and (temp<>'') then
      begin
        if temp = q then
          inc(c);
        temp:=''
      end
    end;
  writeln('Itogo: ',c)
end.

Leave a Comment

+ 46 = 49