Source Code Program Sort Nilai Min_Max
Source Code Program Sort Nilai Min_Max
Dibuat menggunakan Tools Delphi7, dalam rangka penyelesaian tugas MK. Pemrograman Dasar STIKOM Al-Khairiyah Cilegon dengan Dosen Bpk. Berri Prima,S.Kom tahun 2018. Diposting sebagai dokumentasi dan berbagi wawasan tentang dasar pemrograman.
{$APPTYPE CONSOLE}
uses
SysUtils;
const
maks=5;
type
bil = array[1..maks] of integer;
var
bill:bil; i, a, b, j, n : Integer;
avrg : real;
begin
{ TODO -oUser -cConsole Main : Insert code here }
{Input element Array}
writeln('');
writeln(' ======================================');
writeln(' PROGRAM SORTING, MIN MAX DAN RATA-RATA');
writeln(' ======================================');
for i := 1 to maks do
begin
write(' Masukkan Nilai Ke ',i,' : ');
readln(bill[i]);
{PROSEDUR PENUMLAHAN NILAI INPUT}
j := bill[i] + j;
end;
avrg := j div 5;
writeln('');
for b := 1 to maks do {PROSES LOOP UNTUK SORTING}
begin
for a := 1 to maks do {PROSES LOOP UNTUK SELEKSI}
begin
{jika n1 < n2 maka n1 = n2 dan n2 = n1}
if a < maks then
begin
if bill[a] > bill[a+1] then
begin
n := bill[a]; bill[a] := bill[a+1]; bill[a+1] := n;
end;
end
else
begin
if bill[a-1] > bill[a] then
begin
n := bill[a-1]; bill[a] := bill[a-1]; bill[a-1] := n;
end;
end;
end;
end;
{TAMPILKAN NILAI}
writeln(' HASIL SORTING ');
for i := 1 to maks do
begin
writeln(' Nilai Ke ',i,' = ',bill[i]);
end;
writeln('');
writeln(' Total : ', j);
writeln(' Nilai Minimal : ', bill[1]);
writeln(' Nilai Maksimal : ', bill[5]);
writeln(' Nilai Rata-rata :', avrg);
readln;
end.
Contoh running programnya : https://youtu.be/gE08_9zSo78