比赛 暑假培训六 评测结果 EWEEEEEEEE
题目名称 统计数字 最终得分 0
用户昵称 rottenwood 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-23 11:41:42
显示代码纯文本
program pcount;
type
shuzu=array[1..10000] of longint;
shuzu1=array[1..10000,1..10000] of longint;
var
temp,i,j,m,n,x,v:longint;
s:shuzu;
s1:shuzu1;
f1,f2:text;
procedure qsort(l,r:Integer);
var
  i,j,x,y,y1:integer;
begin
  i:=l; j:=r; x:=s1[(l+r) DIV 2,2];
  repeat
    while s1[i,2]<x do i:=i+1;
    while x<s1[j,2] do j:=j-1;
    if i<=j then
    begin
      y:=s1[i,2];y1:=s1[i,1]; s1[i,2]:=s1[j,2];s1[i,1]:=s1[j,1]; s1[j,2]:=y;s1[j,1]:=y1;
      i:=i+1; j:=j-1;
    end;
  until i>j;
  if l<j then qsort(l,j);
  if i<r then qsort(i,r);
end;
begin
assign(f1,'pcount.in');reset(f1);
assign(f2,'pcount.out');rewrite(f2);
readln(f1,n);
fillchar(s,sizeof(s),0);
for i:=1 to n do
begin
readln(f1,x);
inc(s[x]);
end;
temp:=1;   i:=1;
while i<=10000 do
begin
 if s[i]<>0 then
 begin
 s1[temp,1]:=s[i];
 s1[temp,2]:=i;
  inc(temp);
  end;
  inc(i);
 end;
 qsort(1,temp-1);
    for i:=1 to temp-1 do
     writeln(f2,s1[i,2],' ',s1[i,1]);
     close(f2);
     end.