program rrr; uses crt; const n=9; type massiv=array[1..n]of real; var a:massiv; max,sr:integer; procedure vvod(var x:massiv); var i:integer; begin writeln('wwedite massiv'); for i:=1 to n do readln(x[i]); end; procedure vivod(x:massiv); var i:integer; begin for i:=1 to n do write(x[i]:6:2,' '); end; procedure sred_ar_i_max(x:massiv,var sr,max:real); var sum:real; i:integer; begin s:=0; for i:=1 to n do if x[i]>0 then s:=s+x[i]; end; sr:=s/n; for i:=1 to n do if (x[i]>0) and max<x[i] then max:=x[i]; end; vvod(a); clrscr; vivod(a); sred_ar_i_max(a,sr,max); writeln('max=',max:6:2,'srednee arifmet=',sr:6:2); readln; end.
Answers & Comments
Сред. Арифметическое = Сумма всех чисел разделить на количество
(A1 + A2 + A3 + A4 + A5) / 5
program rrr;
uses crt;
const n=9;
type massiv=array[1..n]of real;
var a:massiv;
max,sr:integer;
procedure vvod(var x:massiv);
var i:integer;
begin
writeln('wwedite massiv');
for i:=1 to n do
readln(x[i]);
end;
procedure vivod(x:massiv);
var i:integer;
begin
for i:=1 to n do
write(x[i]:6:2,' ');
end;
procedure sred_ar_i_max(x:massiv,var sr,max:real);
var sum:real; i:integer;
begin
s:=0;
for i:=1 to n do
if x[i]>0 then s:=s+x[i];
end;
sr:=s/n;
for i:=1 to n do
if (x[i]>0) and max<x[i] then max:=x[i];
end;
vvod(a);
clrscr;
vivod(a);
sred_ar_i_max(a,sr,max);
writeln('max=',max:6:2,'srednee arifmet=',sr:6:2);
readln;
end.