比赛 20090923练习赛 评测结果 WAAAAAAAAA
题目名称 背诵单词 最终得分 90
用户昵称 maxiem 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-09-23 20:59:26
显示代码纯文本
program letter;
var
  w:array [1..100] of string;
  l,k,n,i,j:integer;
  tmp:string;
begin
  assign (input,'letter.in');
  reset (input);
  readln (n);
  for i:=1 to n do readln (w[i]);
  close (input);
  assign (output,'letter.out');
  rewrite (output);
  for i:=1 to n-1 do for j:=i+1 to n do if w[i]>w[j] then begin
    tmp:=w[i];
    w[i]:=w[j];
    w[j]:=tmp;
  end;
  i:=1;
  while i<=n do begin
    j:=i;while (j<=n) and (w[i][1]=w[j][1]) do inc(j);dec(j);
    for k:=i to j-1 do for l:=i+1 to j do if (length(w[k])>length(w[l]))  then begin
      tmp:=w[i];
      w[i]:=w[j];
      w[j]:=tmp;
    end;
    i:=j+1;
  end;
  for i:=1 to n do writeln (w[i]);
  close (output);
end.