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

uses
  crt;
var
  s,temp:string;
  i:integer;
begin
  clrscr;
  readln(s);
  temp:='';
  writeln('------: ');
  for i:=1 to length(s) do
  begin
    if s[i]<>' ' then
      temp:=temp+s[i];
    if (s[i]=' ') or (i=length(s)) then
    begin
      if (temp<>'') and (temp[1]=temp[length(temp)]) then
        write(temp,' ');
      temp:=''
    end;
  end
end.

Leave a Comment

− 2 = 1