Дана строка-предложение на латинском языке. Вывести самое короткое слово в предложении. Если таких слов несколько, то вывести первое из них — Pascal(Паскаль)

var
  s,temp,s1:string;
  i:integer;
begin
  readln(s);
  s1:='';
  for i:=1 to  length(s) do
  begin
    if s[i]<>' ' then
      temp:=temp+s[i]
    else
    begin
      if (s1='') and (temp<>'') then
        s1:=temp;
      if (temp<>'') and(length(temp)<length(s1)) then
        s1:=temp;
      temp:=''
    end;
  end;
  if s1<>'' then
    writeln(s1)
end.

Leave a Comment

3 + 6 =