program pengurutan data;
uses wincrt;
const NilaiMaksimum = 1000;
type Larik = array[1..NilaiMaksimum] of integer;
var
L : Larik;
batas : integer;
procedure masukan (var L : Larik; n : integer);
var
a : integer;
begin
for a := 1 to n do
begin
write('Masukkan Nilai Ke-' ,a,' : '); readln(L[a]);
end;
end;
procedure pengurutan (var L : Larik; n : integer);
var
i : integer;
k : integer;
temp : integer;
begin
for i := 1 to (n-1) do
for k := n downto i+1 do
if L[k] < L[k-1] then
begin
temp := L[k];
L[k] := L[k-1];
L[k-1] := temp;
end;
end;
procedure keluaran(var L : Larik; n : integer);
var
i : integer;
begin
for i := 1 to n do
write(L[i]:5);
end;
begin
writeln ('*******************************************') ;
write('Masukkan Jumlah Elemen yang diinginkan : '); readln(batas);
writeln ('*******************************************') ;
writeln;
masukan(L,batas) ; writeln;
pengurutan (L,batas); writeln;
writeln ('************************') ;
writeln('Hasil Pengurutan Larik : ');
writeln ('************************') ;
keluaran(L,batas);