program Project1;
const
//Множество разделителей слов.
D = [' ', '.', ',', ':', ';', '!', '?', '-', #9, #10, #13];
var
S : String;
i, Pos1, Len, LenW, LenWMax, LenWMin : Integer;
begin
repeat
Writeln('Задайте текст:');
Readln(S);
//Обработка текста.
Len := Length(S);
LenWMin := Len;
LenWMax := 0;
Pos1 := 0;
for i := 1 to Len do begin
//Пропускаем разделители.
if S[i] in D then Continue;
//Отслеживаем начало слова.
if (i = 1) or (S[i - 1] in D) then Pos1 := i;
//Отслеживаем конец слова.
if (i = Len) or (S[i + 1] in D) then begin
//Вычисляем длину слова.
LenW := i - Pos1 + 1;
if LenW > LenWMax then LenWMax := LenW;
if LenW < LenWMin then LenWMin := LenW;
end;
end;
//Показываем результат.
if LenWMax > 0 then begin
Writeln('Длина самого короткого слова: ', LenWMin);
Writeln('Длина самого длинного слова: ', LenWMax);
end else begin
Writeln('В строке нет слов.');
end;
Writeln('Повторить - Enter, выход - любой символ + Enter.');
Readln(S);
until S <> '';
end.