Задана строка символов. Группы символов, разделенные пробелом, будем называть словами. Вывести самое длинное слово в строке и его длину — Pascal(Паскаль)

uses
  crt;
const
  dividers=[' ',',','.',';',':','-','=','+'];
var
  s,temp,max:string;
  i,j:integer;
begin
  clrscr;
  writeln('Vvedite stroku...');
  readln(s);
  temp:='';
  max:='';
 
  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)) then
    begin
      if temp<>'' then
      begin
        if Length(temp)>Length(max) then
          max:=temp;
        temp:=''
      end;
    end;
  end;
  writeln('Max stroka : ',max,'. Dlina: ',Length(max))
end.

Leave a Comment

49 + = 53