记录编号 23914 评测结果 AAAAAAAAAA
题目名称 NBA总冠军 最终得分 100
用户昵称 Gravatarecho 是否通过 通过
代码语言 Pascal 运行时间 0.022 s
提交时间 2011-03-24 12:48:17 内存使用 0.15 MiB
显示代码纯文本
program nba;
var
   n,i,j,julu,k,l:longint;
   s,year,na:array[1..50] of string;
   long:array[1..50] of longint;
   t:string;
begin
  assign(input,'nba.in');
  reset(input);
  assign(output,'nba.out');
  rewrite(output);
  readln(n);
  for i:=1 to n do readln(s[i]);
  for i:=1 to n do long[i]:=length(s[i]);
  for i:=1 to n do
    begin
      year[i]:=copy(s[i],long[i]-3,4);
      na[i]:=copy(s[i],1,long[i]-5);
    end;

  for i:= 1 to n-1 do
    for j:=i+1 to n do
     if (year[i]>year[j])and(year[j]<>'')and(i<>j)
       then
         begin
           t:=year[i]; year[i]:=year[j]; year[j]:=t;
           t:=na[i]; na[i]:= na[j]; na[j]:=t;
         end
       else
         begin
          for l:=j to n do
           if (year[i]=year[l])and(year[i]<>'')and(year[l]<>'')and(i<>l)
             then
               begin
                 if l>i then for k:=l to n do
                   begin
                     year[k]:=year[k+1];
                     na[k]:=na[k+1];
                     if (year[i]>year[l])and(year[l]<>'')and(i<>l)then
                          begin
                             t:=year[i]; year[i]:=year[l]; year[l]:=t;
                             t:=na[i]; na[i]:= na[l]; na[l]:=t;
                          end;
                   end
                        else for k:=i to n do
                   begin
                     year[k]:=year[k+1];
                     na[k]:=na[k+1];
                     if (year[i]>year[l])and(year[l]<>'')and(i<>l)then
                          begin
                             t:=year[i]; year[i]:=year[l]; year[l]:=t;
                             t:=na[i]; na[i]:= na[l]; na[l]:=t;
                          end
                   end;
               end;
         end;
  for i:=1 to n do
   writeln(year[i],' ',na[i]);
   close(input);
   close(output);
end.