program TheIdiotiestProgrammIveEVERseen2;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
slovo:array[0..29] of string;
stroka:string;
i,k,lol,dlinna,m:byte;
function IsOk(a:string):boolean;
var i:integer;
begin
IsOk:=true;
For i:=0 to length(a)-1 do
begin
If a[i]>a[i+1] then IsOk:=false;
end;
end;
{end of IsOk}
{Nachalo}
begin
writeln('Enter words(not more than 30): ');
readln(stroka);
dlinna:=length(stroka);
For i:=1 to length(stroka) do
begin
if stroka[i]='.' then
begin
insert(' ',stroka,i); delete(stroka,i+1,length(stroka)-i+1);
end;
end;
For i:=0 to length(stroka) do
begin
if (stroka[i]=' ') and (stroka[i]<>stroka[i+1]) then m:=m+1;
end;
For k:=0 to dlinna do
begin
If length(stroka)>0 then begin
For i:=1 to length(stroka) do
If (stroka[i]<>' ') then
begin
insert(stroka[i], slovo[k], i);
lol:=i;
end
else if (stroka[i]=' ') and (stroka[i-1]<>' ') then
begin
delete(stroka, 1, lol+1);
break;
end
else if (stroka[i]=' ') and (stroka[i+1]=' ') then
begin
delete(stroka, 1, 1);
break;
end
else breaK;
end;
end;
writeln;
writeln('Slova, s bukvami, stoyashimi v alfavitnom poryadke.');
writeln('------------------------------------------------------------------');
For k:=0 to dlinna do begin
If (IsOk(slovo[k])=true) then write(Slovo[k], ' ');
end;
writeln;
writeln('------------------------------------------------------------------');
writeln;
writeln('Press enter to exit');
readln;
end.