Program urut;
uses wincrt;
type
indeks=1..30;
vektor=array[indeks] of real;
var
a:vektor;
cad:real;
j,i,n:word;
procedure sort(var a:vektor);
begin
for i:=1 to n do
begin
for j:=i+1 to n do
begin
if a[i]>a[j] then
begin
cad:=a[i];
a[i]:=a[j];
a[j]:=cad;
end;
end;
end;
end;
Procedure input(var a:vektor);
begin
for i:=1 to n do
begin
write('a[',i,']');readln(a[i]);
end;
end;
procedure output(var a:vektor);
begin
for i:=1 to n do
begin
writeln (a[i]:6:3);
end;
end;
begin
clrscr;
write('jumlah data');readln(n);
input(a);
writeln('data sebelum di urut :');
output(a);
sort(a);
writeln('data setelah diurut adalah: ');
output(a);
end.
0 Komentar:
Posting Komentar