Cod sursa(job #197237)

Utilizator theratmantheratman theratman Data 2 iulie 2008 22:16:35
Problema Ordine Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.54 kb
var f,g:text;
    x:char;
    i:longint;
    a:array[1..26]of longint;
begin
assign(f,'ordine.in');reset(f);
assign(g,'ordine.out');rewrite(g);
while not eof(f) do begin
 while not eoln(f) do begin
  read(f,x);
  inc(a[ord(x)-96])
 end;
 readln(f);
end;
for i:=1 to 25 do
 if a[i]>1 then begin
  while a[i]>1 do begin
   write(g,chr(i+96),chr(i+97));
   dec(a[i]);
   dec(a[i+1]);
  end;
  write(g,chr(i+96));
 end
  else
   if a[i]=1 then
    write(g,chr(i+96));
if a[26]=1 then write(g,'z');
close(f);
close(g);
end.