program latihan3;
uses wincrt;
const
N=10;
larik: array [1..10] of integer = (5,100,20,31,77,88,99,20,55,1);
var
j,k,temp : integer;
begin
clrscr;
writeln ('sebelum diurutkan');
for j:=1 to N do begin
write(larik [j]:5);
end;
writeln;
for j:=1 to N-1 do
begin
for k :=2 to N do
begin
if larik[k] < larik[k-1] then
begin
temp := larik[k];
larik[k] := larik[k-1];
larik[k-1] :=temp;
end;
end;
end;
writeln;
writeln ('setelah diurutkan ');
for j:=1 to N do
begin
write(larik[j]:5);
end;
writeln;
end.
HASIL
Artikel Terkait:
0 komentar:
Posting Komentar