program ascending;
uses wincrt;
type
T = array[1..100] of integer;
procedure ascend (a : T; var temp : integer );
var
i,n,j,min : integer;
begin
for i:=1 to (n-1) do
begin
min:=i;
for j:=(i+1) to n do
begin
if a[min]>a[j] then
begin
min := j;
end;
end;
temp := a[i];
a[i] := a[min];
a[min] := temp;
writeln;
end;
end;
var
a : T;
i,n,temp,min : integer;
begin
write('batas: '); readln(n);
for i:=1 to n do
begin
write('nilai',i,'='); readln(a[i]);
end;
writeln;
ascend(a,temp);
write(a[i]);
end.
uses wincrt;
type
T = array[1..100] of integer;
procedure ascend (a : T; var temp : integer );
var
i,n,j,min : integer;
begin
for i:=1 to (n-1) do
begin
min:=i;
for j:=(i+1) to n do
begin
if a[min]>a[j] then
begin
min := j;
end;
end;
temp := a[i];
a[i] := a[min];
a[min] := temp;
writeln;
end;
end;
var
a : T;
i,n,temp,min : integer;
begin
write('batas: '); readln(n);
for i:=1 to n do
begin
write('nilai',i,'='); readln(a[i]);
end;
writeln;
ascend(a,temp);
write(a[i]);
end.
No comments:
Post a Comment