Ввести строку символов. Упорядочить слова в строке по алфавиту. Количество пробелов произвольная — Pascal(Паскаль)

uses crt;
var
  b:array[1..100]of string;
  a,t:string;
  i,l,j:integer;
begin
read(a);
i:=1;
l:=0;
while (i <= length(a)) do
begin
     while ((a[i]=' ')and(i <= length(a)))do
         inc(i);
     inc(l);
     b[l]:='';
     while ((a[i]<>' ')and(i <= length(a)))do
     begin
          b[l]:=b[l]+a[i];
          inc(i);
     end;
end;
if a[length(a)]=' ' then dec(l);
for i:=1 to l - 1 do
   for j:=i+1 to l do
       if b[i] > b[j] then
       begin
            t:=b[i];
            b[i]:=b[j];
            b[j]:=t;
       end;
for i:=1 to l do
write(b[i],' ');
end.

Leave a Comment

+ 84 = 90