Minggu, 05 April 2015

Program Pascal Extreme Search

Tags

Contoh program pascal mencari nilai terbesar dan nilai terkecil menggunakan extreme search.



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;
  Write('Jumlah Data = '); readln(jlh);
  Writeln;
  Write('Inputkan Data = ');
  For i:= 1 to jlh do
    Begin
      Gotoxy(13+(i*4),6); readln(tabint[i]);
    End;
  Writeln;
  Maks:=maksimum(tabint, jlh);
  Minm:=minimum(tabint, jlh);
  Writeln('Nilai Terbesar = ',maks);
  Writeln('Nilai Terkecil = ',minm);
  Readln;
End.


Output :
1. Input jumlah data



2. Input data



3. Hasil searching


EmoticonEmoticon