Cod sursa(job #111581)
Utilizator | qwertyldskfn Allosaurus | Data | 30 noiembrie 2007 20:53:17 |
---|---|---|---|
Problema | Ordine | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
Var f,g:Text;
x,s,p:String;
i,j,a:Longint;
Begin
Assign(f,'ordine.in'); ReSet(f);
Assign(g,'ordine.out'); ReWrite(g);
readln(f,s);
p:='';
For i:=1 To Length(s) Do Begin
x:=s[i];
a:=Length(p);
If p='' Then p:=p+x;
For j:=1 To Length(p) Do
If (x<p[j])and(x<>p[j])and(x<>p[j-1]) Then Begin
Insert(x,p,j);
Break;
End;
If (j=Length(p))and(a=length(p)) Then p:=p+x;
End;
WriteLn(g,p);
Close(f);
Close(g);
End.