Program Pascal : Mencari Letak Posisi Nilai Terkecil

Program min_akhir;
uses wincrt;
type tabint = array[1..100]of integer;

function posisi_min_akhir(a:tabint; n:integer):integer;
var i,j,k:integer;
begin
k:=1;
j:=a[1];
for i:=2 to n do
    begin
    if a[i]<=j then
       begin
       j:=a[i];
       k:=i;
       end
    end;
posisi_min_akhir := k;
end;

var T:tabint;
    i,n,z:integer;
begin
write('Masukan batas = ');readln(n);
for i:=1 to n do
    begin
    write(i,' = ');readln(T[i]);
    end;
z := posisi_min_akhir(T,n);
writeln(z);
end.

0 comments:

Komentar