Program zad9_33;
uses crt;
var s:string;
Procedure DelSpaces(Var s:string);
begin
while (s[1]=' ') and (length(s)>0) do
s:=copy(s,2,length(s)-1);
end;
Procedure Words(S:string);
var last:string;
slovo:string;
i:integer;
Function Rep(slovo:string):Boolean;
var ch:char;
Begin
repeat
ch:=slovo[1];
Delete(slovo,1,1);
until (pos(ch,s)>0) or (s='');
Rep:=(s<>'');
end;
begin
i:=Length(s);
While (s[i]<>'') and (i>1) do Dec(i);
last:=Copy(s,i+1,Length(s)-i);
Delete(s,i,Length(last));
s:=s+' ';
DelSpaces(s);
While s<>'' do begin
slovo:=Copy(s,1,Pos(' ',s)-1);
Delete(s,1,Length(slovo));
if (slovo<>last) and not Rep(slovo) then
write(slovo,' ');
DelSpaces(s);
end;
end;
BEGIN
writeln('Vvedite text: ');
readln(s);
words(s);
readln;
END.