比赛 暑假培训六 评测结果 AWWWWWWWWW
题目名称 明明的随机数 最终得分 10
用户昵称 Hamster 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-23 09:55:52
显示代码纯文本
program random;
var
  a:array[1..101] of integer;
  n,i,j:integer;
  fin,fout:text;

procedure init;
var
  temp:integer;
begin
  readln(fin,n);
  for i:=1 to n do
  begin
    read(fin,a[i]);
  end;
  for i:=2 to n+1 do
    for j:=1 to i-1 do
    begin
      if a[j]>a[i] then
      begin
        temp:=a[j];
        a[j]:=a[i];
        a[i]:=temp;
      end;
    end;
end;

procedure print;
var
  q:integer;
begin
  q:=0;
  for i:=2 to n+1 do
    if a[i]<>a[i-1] then inc(q)
    else a[i]:=0;
  writeln(fout,q);
  for i:=2 to n do
    if a[i]<>0 then write(fout,a[i],' ');
  write(fout,a[n+1]);
end;

begin
  assign(fin,'random.in');
  reset(fin);
  assign(fout,'random.out');
  rewrite(fout);

  init;
  print;

  close(fin);
  close(fout);
end.