var
st:string; {строка вводимых слов}
words:array[1..20]of string; {массив из отдельных слов}
i,j,max:integer;
BEGIN
writeln('Введите строку слов:');
readln(st);
for i:=1 to 20 do words[i]:=''; {массив делаем пустым}
j:=1;
for i:=1 to length(st) do {загружаем слова в массив из строки}
begin
if st[i]<>' ' then words[j]:=words[j]+st[i] else
if st[i-1]<>' ' then inc(j);
end;
max:=j; {всего слов}
for i:=1 to max do writeln(words[i]); {напечатаем полученный массив слов}
{отсортируем массив по убыванию}
for i:=1 to max-1 do
for j:=i+1 to max do if words[i]>words[j] then
begin
st:=words[i];
words[i]:=words[j];
words[j]:=st;
end;
writeln;
for i:=1 to max do writeln(words[i]); {напечатаем отсортированный массив}
readln;
END.