program bubble_sort;
uses crt;
var
i,n,j : integer;
a : array [1..10] of integer;
procedure urutkan;
var
z : integer;
begin
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;
end;
begin
clrscr;
write ('Masukkan banyak data yang ingin di urut : '); readln(n);
for i:=1 to n do
begin
write ('Data ',i,' : '); readln(a[i]);
end;
urutkan;
write('Data setelah diurutkan : ');
for j:=1 to n do
write (a[j],' ');
readln;
end.
JANGAN LUPA TULISKAN KOMENTAR
TERIMA KASIH
uses crt;
var
i,n,j : integer;
a : array [1..10] of integer;
procedure urutkan;
var
z : integer;
begin
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;
end;
begin
clrscr;
write ('Masukkan banyak data yang ingin di urut : '); readln(n);
for i:=1 to n do
begin
write ('Data ',i,' : '); readln(a[i]);
end;
urutkan;
write('Data setelah diurutkan : ');
for j:=1 to n do
write (a[j],' ');
readln;
end.
JANGAN LUPA TULISKAN KOMENTAR
TERIMA KASIH
0 komentar:
Posting Komentar