program Cari_Nilai_Maks_Min ;
uses crt ;
var
i, n, max, min : integer ;
list : array [1..100] of integer ;
ch : char ;
Begin
repeat
clrscr;
write('Banyak data : ');
repeat
gotoxy(40,1);
clreol;
readln(n);
until (n>0) and (n<=100);
randomize;
for i := 1 to n do
begin
list [i] := random(1000);
write(list [i] : 5);
if (i mod 12 = 0) then writeln;
end;
min := list [i];
max := list [i];
for i := 1 to n do
begin
if min > list [i] then min := list [i];
if max < list [i] then max := list [i];
end;
writeln;writeln;
writeln('Nilai maksimum : ', max);
writeln('Nilai minimum : ', min);
gotoxy(20,24);
writeln('Mau ulang lagi? [Y/N] ');
repeat
ch := readkey until upcase(ch) in ['Y' , 'N'];
until upcase(ch) = 'N';
end.
Tidak ada komentar:
Posting Komentar