讨论 / 求大神指教问题在哪
GSWbro 2016-09-28 03:59:28
点我顶贴 收藏 删除
var

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

i,j,n,d,s:integer;

begin

readln(n);

for i:=1 to n do

read(a[i]);

for i:=1 to n do begin

for j:=i+1 to n do begin

if (a[i]=a[j]) and (a[i]<>0) and (a[j]<>0) then a[j]:=0;

end;

end;

for i:=1 to n do

if a[i]<> 0 then s:=s+1;

for j:=i+1 to n do begin

if (a[i]<>0) and (a[j]<>0) and (a[i]>a[j]) then begin

d:=a[i];

a[i]:=a[j];

a[j]:=d;

end;

end;

writeln(s);

for i:=1 to n do begin

if a[i]<>0 then write(a[i],' ');

end;

end.

查看更多回复
提交回复