编译通过...

├ 测试数据 01:答案正确... 0ms

├ 测试数据 02:答案正确... 0ms

├ 测试数据 03:答案正确... 0ms

├ 测试数据 04:答案正确... 0ms

├ 测试数据 05:答案正确... 0ms

├ 测试数据 06:答案正确... 0ms

├ 测试数据 07:答案正确... 0ms

├ 测试数据 08:答案正确... 0ms

├ 测试数据 09:答案正确... 0ms

├ 测试数据 10:答案正确... 0ms

---|---|---|---|---|---|---|---|-

Accepted 有效得分:100 有效耗时:0ms

var s,j,q,i,n,k:longint;

a:array[1..100]of longint;

begin

readln(n);

for i:=1 to n do

begin

k:=k+1;

read(a[k]);

q:=0;

for j:=1 to k-1 do if a[k]=a[j] then q:=1;

if q=1 then k:=k-1;

end;

writeln(k);

for i:=1 to k-1 do

for j:=i+1 to k do

if a[i]>a[j] then

begin

s:=a[i];

a[i]:=a[j];

a[j]:=s;

end;

for i:=1 to k do

write(a[i],' ');

readln;

readln

end.

3 条评论

  • @ 2014-08-13 18:41:13

    var
    n,i,l,r,k,q:longint;
    a:array[1..1000000] of longint;
    procedure qsort(l,r:longint);
    var
    i,j,mid,p:longint;
    begin
    i:=l; j:=r;
    mid :=a[(i+r) div 2] ;
    repeat
    while a[i] <mid do inc(i);
    while a[j] >mid do dec(j);
    if i<=j then
    begin
    p:=a[i]; a[i]:=a[j]; a[j]:=p; inc(i); dec(j);
    end;
    until i>j;
    if l<j then qsort(l,j);
    if i<r then qsort(i,r);
    end;
    begin
    k:=0;
    readln(n);
    for i:= 1 to n do
    read(a[i]);
    l:=1;r:=n;
    qsort(l,r);
    for i:= 1 to n do
    if a[i]=a[i+1] then a[i]:=0;
    for i:= 1 to n do
    if a[i]<>0 then k:=k+1;
    writeln(k);
    for i:=1 to n do
    if a[i]<>0 then write(a[i],' ') ;
    end.

  • @ 2014-08-13 18:41:07

    。。。

  • @ 2009-07-11 11:58:16

    你的方法有点烦,用散列表即可

  • 1

信息

ID
1316
难度
3
分类
其他 | 排序 点击显示
标签
递交数
9946
已通过
4861
通过率
49%
被复制
29
上传者