求此pascal题的的程序~~~难啊~~~

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:41:14
这道题必须用一维数组做哦~~~
题目:
任意键输入一组数组(10个自然数)
1.排序,从小到大
2.如果数组中有相同的数,请删除多余只剩一个
3.按从小到大的序列打印
如对题有意见请提出~~

var n,i,k,j,t:integer;
c:array[1..1000] of boolean;
a,b:array[1..10000] of integer;
begin
n:=10;
fillchar(c,sizeof(c),true);
for i:=1 to n do read(a[i]);
for i:=1 to n do
begin
if c[a[i]]=true then begin inc(k);b[k]:=a[i];c[a[i]]:=false;end;
end;
writeln(k);
for i:=1 to k-1 do
for j:=1 to k-1 do
begin
if b[j]>b[j+1] then begin t:=b[j];b[j]:=b[j+1];b[j+1]:=t;end;
end;
for i:=1 to k do write(b[i],' ');
end.

var h:array[0..10000]of boolean;
i,temp,max:longint;
begin
fillchar(h,sizeof(h),false);
max:=-maxlongint;
for i:=1 to 10 do
begin
read(temp);
h[temp]:=true;
if temp>max then max:=temp;
end;
readln;
for i:=0 to max-1 do
if h[i] then write(i,' ');
writeln(max);
end.

绝对保证速度

var
a,b,c:longint;
s:a