求桶排序pascal代码

来源:百度知道 编辑:UC知道 时间:2024/06/14 01:10:37
求桶排序pascal代码

var used:array [1..10000000] of boolean;
n,i,j:longint;
begin
readln(n);
fillchar(used,sizeof(used),false);
for i:=1 to n do
begin
read(j);
used[j]:=true;
end;
for i:=1 to n do
if used[i] then write(i,' ');
end.

const max=1000000;
var a:array[1..max]of integer;
n:longint;
i,j:longint;
begin
readln(n);
for i:=1 to n do
begin
read(j);
inc(a[j]);
end;
for i:=1 to max do
for j:=1 to a[i] do write(i,' ');
writeln;
end.

type datatype=record
num,tot,next:longint; //依次为数值,个数,指向下一个值的指针
end;
const max=1000000; //最大数的值
total=1000000; //总共有多少个数
p=100; //装入每个桶的元素
var i,j,k,n,tail:longint;
data:array[0..total] of datatype;
a:array[0..max div p] of longint;
procedure main;
var s,t,num:longint;
begin