program bubblesort

Document Sample
program bubblesort Powered By Docstoc
					program bubblesort;
uses wincrt;
const NMaks=1000;
type larik=array[1..nmaks] of integer;
var
l:larik;
n:integer;
procedure baca(var l:larik;n:integer);
var
i:integer;
begin
for i:=1 to n do
begin
write('l[',i,']:');readln(l[i]);
end;
end;

Procedure Bubble(VAR L:Larik; N:Integer);
VAR
I,K,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-1]:=temp;
end;
end;



procedure tulis (var l:larik ; n:integer);
var
i:integer;
begin
for i:= 1 to n do
write(l[i]:5)
end;
begin
write('masukkan n :');readln (n);
baca (l,n);
writeln;
bubble(l,n);
end.

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:29
posted:6/22/2011
language:Indonesian
pages:1