Minggu, 05 April 2015

Ekstrim Search ( Data Terbesar - Terkecil )

Assalamu'alaikum wr. wb.
Alhamdulillahirobbil'alamin
Program keempat Algoritma & Pemrograman II Selesai
1. Screen Shot Program
Gambar 1.1 Tampilan program maxmin yaitu input jumlah data dan data.

2. Source Code Program
Program MaxMin;
Uses crt;
Var data : array [1..50] of integer;
    n,i,j,temp,max,min : integer;
BEGIN
    clrscr;
    Writeln('Ekstrim Search Max-Min ');
    Writeln('~~~~~~~~~~~~~~~~~~~~~~');
    Writeln;
    Write  ('Input Jumlah Data : '); readln(n);
    writeln('~~~~~~~~~~~~~~~~~~~~~');
    for i:=1 to n do
     begin
      write ('Data ke- ',i,' : ');
      readln(data[i]);
     end;
      writeln;

    for i:=n-1 downto 1 do
     for j:= 1 to i do
     if data[j] > data[j+1] then
      Begin
       temp:=data[j];
       data[j]:=data[j+1];
       data[j+1]:=temp;
      End;

    Writeln('Data Terurut : ');
    writeln('~~~~~~~~~~~~~~');
    max:=data[1];
    min:=data[1];
    For i:= 1 to n do
      Begin
       Write(data[i],' ');
       if (max<data[i]) then max:=data[i]
       else
       min:=data[i];
      End;

 writeln;
 writeln;
 Writeln('Data Terkecil : ',min);
 writeln('~~~~~~~~~~~~~~~~~~');
 Writeln('Data Terbesar : ',max);
 writeln('~~~~~~~~~~~~~~~~~~');
 readkey;
END.

0 komentar :

Posting Komentar