Senin, 23 April 2012

Program arh_bsort_menaik; ( Struktur Data )


Program arh_bsort_menaik;

uses crt;

var i,n,j,z : integer;
a: array [1..100] of integer;

begin
write('masukkan banyak larik  : '); readln(n);
for i:= 1 to n do
begin
write('A[',i,'] : '); readln(a[i]);
end;

for i:= 1 to n-1 do
begin
for j:= n downto i+1 do
begin
if a[j] < a[j-1] then
begin
z:= a[j];
a[j]:= a[j-1];
a[j-1]:=z;
end;
end;
end;


write('data setelah diurutkan : ');

for j:=1 to n do
write (a[j],' ');
readln;
end.

Tidak ada komentar:

Posting Komentar