program pengurutan;
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
clrscr;
write('Urutan Maksimum = ');
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;
writeln;
end;
procedure urut_min;
begin
write('Urutan Minimum = ');
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 diurut : ');
writeln('------------------------');
urut_maks;
urut_min;
readln;
end.
Jumat, 25 Maret 2011
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar