1.
Screenshot
Program
Gambar
5 : Tampilan Hasil Pencarian Nialai Terbesar dan Terkecil
2.
Source
Code
Program
extreme_search;
Uses crt;
Type
Arrint = array [1..100] of integer;
Var
maks, minm, jlh, i : integer;
tabint : arrint;
Function
maksimum(tabint : arrint; n : integer) : integer;
Var
i,max : integer;
Begin
For i:=1 to n do
If max < tabint[i] then
Max:= tabint[i];
Maksimum:=max;
End;
Function
minimum(tabint : arrint; n : integer) : integer;
Var
i,min : integer;
Begin
For i:=1 to n do
If min > tabint[i] then
Min:= tabint[i];
Minimum:=min;
End;
Begin
Clrscr;
Writeln('
>>> Program Extreme Search <<< ');
Writeln('--------------------------------------');
writeln('Menentukan Nilai Terbesar dan
Terkecil');
writeln;
Write('Jumlah Data = '); readln(jlh);
Writeln;
Write('Inputkan Data = ');
For i:= 1 to jlh do
Begin
Gotoxy(13+(i*4),7); readln(tabint[i]);
End;
Writeln;
Maks:=maksimum(tabint, jlh);
Minm:=minimum(tabint, jlh);
Writeln('Nilai Terbesar = ',maks);
Writeln('Nilai Terkecil = ',minm);
Readln;
End.
|
Posting Komentar