Program median;
Uses Wincrt;
Var
x: array [1..100]
of integer;
n,i,pos:integer;
md:real;
Begin
writeln('=============');
Writeln('Program
median');
Writeln('=============');
Writeln;
writeln('*dalam
program ini, data yang harus dimasukkan
nanti harus sudah urut*');
writeln;
Write('Masukkan
Jumlah Data (n): ');readln(n);
md:=0;
For i:= 1 to n do
Readln(x[i]);
Writeln;
For i:= 1 to n do
if (n mod 2 = 1)
then
begin
pos:=(n div 2)+1;
md:=x[pos];
end
else
begin
pos:=(n div 2);
md:=(x[pos]+x[pos+1])/2;
end;
writeln;
Writeln('Median
dari data berjumlah ', n,' tadi adalah : ',md:0:2);
End.
ConversionConversion EmoticonEmoticon