Дано предложение, состоящее не менее чем из 5 слов. Напечатать все слова из предложения, содержащие ровно две буквы «d»- Pascal(Паскаль)

uses
  Crt;
  
const
  dividers = [' ',',','.',';',':','-','=','+'];
 
function F(s: string; ch: char): byte;
var
  i,c: byte;
begin
  c := 0;
  for i := 1 to Length(s) do
    if s[i] = ch then
      Inc(c);
  F := c
end;
 
var
  s,temp: string;
  i: integer;
begin
  ClrScr;
  ReadLn(s);
  temp := '';
  WriteLn(': ');
  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 F(temp, 'd') = 2 then
        Write(temp, ' ');
      temp := '';
    end
  end;
end.

Leave a Comment

− 1 = 1