program penggurutan;
uses wincrt;
const
maks=100;
type
daf_urut=array[1..maks]of integer;
var
urut:daf_urut;
x,z,temp,data:integer;
procedure urut_maks;
begin
write('naik = ');
for x:=1 to data do
begin
for z:=x to data do
begin
if urut[z] < urut[x] then
begin
temp:=urut[z];
urut[z]:=urut[z];
urut[x]:=temp;
end;
end;
write(urut[x],' ');
end;
writeln;
end;
procedure urut_min;
begin
write('Menurun = ');
for x:=1 to data do
begin
for z:=x to data do
begin
if urut[z] > urut[x] then
begin
temp:=urut[z];
urut[z]:=urut[x];
urut[x]:=temp;
end;
end;
write(urut[x],' ');
end;
end;
begin
write('banyak data = ');readln(data);
writeln('-------------');
for x:=1 to data do
begin
write('data ke-',x,' = ');readln(urut[x]);
end;
writeln;
writeln;
writeln('data setelah di urut :');
writeln('----------------------');
urut_maks;
urut_min;
end.
0 komentar:
Post a Comment
Tinggalkan Komentar Disini