Pagini recente » Cod sursa (job #2617202) | Cod sursa (job #2953537) | Cod sursa (job #2171554) | Cod sursa (job #2353449) | Cod sursa (job #110226)
Cod sursa(job #110226)
var v:array[1..1000000]of char;
ordo:boolean;i,n,j:longint;aux:char;
begin
assign(input,'ordine.in');reset(input);
assign(output,'ordine.out');rewrite(output);
i:=0;
while not eof do begin
inc(i);
read(v[i]);
end;
n:=i;
repeat
ordo:=true;
for i:=1 to n-1 do
if v[i]>v[i+1]then begin
ordo:=false;
aux:=v[i];
v[i]:=v[i+1];
v[i+1]:=aux;
end;
until ordo;
for i:=1 to n-1 do
if v[i]=v[i+1] then
if i<n-1 then begin
j:=i+2; ordo:=false;
repeat
if v[i+1]<>v[j] then begin
aux:=v[i+1];
v[i+1]:=v[j];
v[j]:=aux;
ordo:=true
end;
inc(j);
until ordo;
end;
for i:=1 to n do write(v[i]);
end.