Program interval;
uses wincrt;
type tabin=array [1..200] of integer;
function mean (a:tabin; n:integer):real;
var
i,domp:integer;
begin
domp:=0;
for i:= 1 to n do
domp:=domp+a[i];
mean:=domp/n;
end;
function ttktngah(a:tabin; n:integer):real;
begin
if n mod 2 = 0 then
ttktngah:=(a[n div 2]+a[(n div 2)+1])/2
else
ttktngah:=(a[(n div 2)+1]);
end;
var
a:tabin;
i,n:integer;
hsl,hsl2:real;
begin
write('masukan batas : ');readln(n);
for i:= 1 to n do
begin
write('masukan data ke ',i,' : ');readln(a[i]);
end;
hsl:=mean(a,n);
write('mean : ',hsl:0:2);
hsl2:=ttktngah(a,n);
writeln;
writeln('titik tengah : ',hsl2:0:2);
end.
No comments:
Post a Comment