Pagini recente » Cod sursa (job #605847) | Cod sursa (job #1260995) | Cod sursa (job #1995703) | Monitorul de evaluare | Cod sursa (job #575061)
Cod sursa(job #575061)
program stefi;
var f,g:text;
a:array['a'..'z']of longint;
b:array[1..10000]of char;
j,c:char;
n,i,q:longint;
begin
assign(f,'ordine.in');
reset(f);
while not(eoln(f))do
begin
read(f,c);
inc(a[c]);
inc(n);
end;
close(f);
assign(g,'ordine.out');
rewrite(g);
for i:=1 to n do
begin
for j:='a'to'z' do
begin
if (b[q]<>j)and(a[j]<>0) then
begin
inc(q);
b[q]:=chr(ord(j));
dec(a[j]);
write(g,j);
break;
end;
end;
end;
close(g);
end.