讨论 / 明明的随机数AC题解 绝对满分!!
大名鼎鼎的张嘉豪 2011-06-06 01:24:00
点我顶贴 收藏 删除
相信我吧!

程序:

var a,b:array[1..100] of longint;

n,i,j,t,x:longint;

begin

readln(n);

for i:=1 to n do read(a[i]);

for i:=1 to n do

for j:=1 to n-i do

if a[j]>a[j+1] then begin

t:=a[j];

a[j]:=a[j+1];

a[j+1]:=t;

end;

for i:=1 to n-1 do

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

for i:=1 to n do if a[i]<>0 then x:=x+1;

writeln(x);

j:=0;

for i:=1 to n do if a[i]<>0 then begin

inc(j);

b[j]:=a[i];

end;

for i:=1 to j-1 do write(b[i],' ');

writeln(b[j]);

end.

查看更多回复
提交回复