program lokasi;
uses wincrt;
type tipelarik=array [1..100] of real;
var e,c,m:integer;
d:tipelarik;
procedure tukarkan(var a,b:real);
var t:real;
begin
t:=a;
a:=b;
b:=t;
end;
procedure sisip_langsung(var a:tipelarik;n:integer);
var i,j:integer; t:real;
begin
for i:=2 to n do
begin
t:=a[i];j:=i-1;
a[0]:=t;
while t< a[j] do
begin
a[j+1]:=a[j];
dec(j);
end;
a[j+1]:=t;
end;
end;
begin
write('jumlah data');readln(m);
for e:=1 to m do
readln(d[e]);
sisip_langsung(d,m);
for c:=1 to m do
writeln(d[c]:0:0)
end.
Continue Reading...
uses wincrt;
type tipelarik=array [1..100] of real;
var e,c,m:integer;
d:tipelarik;
procedure tukarkan(var a,b:real);
var t:real;
begin
t:=a;
a:=b;
b:=t;
end;
procedure sisip_langsung(var a:tipelarik;n:integer);
var i,j:integer; t:real;
begin
for i:=2 to n do
begin
t:=a[i];j:=i-1;
a[0]:=t;
while t< a[j] do
begin
a[j+1]:=a[j];
dec(j);
end;
a[j+1]:=t;
end;
end;
begin
write('jumlah data');readln(m);
for e:=1 to m do
readln(d[e]);
sisip_langsung(d,m);
for c:=1 to m do
writeln(d[c]:0:0)
end.