Var a : array [1..3] of array [1..3] of integer; i,j : shortint; c1,c2,s1,s2 : integer;
begin a[1][1]:=-10; a[1][2]:=20; a[1][3]:=13; a[2][1]:=-22; a[2][2]:=11; a[2][3]:=-5; a[3][1]:=4; a[3][2]:=12; a[3][3]:=-8; s1:=0; s2:=0; c1:=0; c2:=0; for i:=1 to 3 do begin for j:=1 to 3 do begin if a[i][j]>0 then begin s1:=s1+a[i][j]; inc (c1); end else begin s2:=s2+a[i][j]; inc (c2); end; end; end; writeln (s1/c1:0:0); writeln (s2/c2:0:2); end.
i,j : shortint;
c1,c2,s1,s2 : integer;
begin
a[1][1]:=-10;
a[1][2]:=20;
a[1][3]:=13;
a[2][1]:=-22;
a[2][2]:=11;
a[2][3]:=-5;
a[3][1]:=4;
a[3][2]:=12;
a[3][3]:=-8;
s1:=0; s2:=0; c1:=0; c2:=0;
for i:=1 to 3 do begin
for j:=1 to 3 do begin
if a[i][j]>0 then begin
s1:=s1+a[i][j];
inc (c1);
end else begin
s2:=s2+a[i][j];
inc (c2);
end;
end;
end;
writeln (s1/c1:0:0);
writeln (s2/c2:0:2);
end.
program Geom;
program Test_nn;
{$APPTYPE CONSOLE}
{$R *.res}
uses
Math;
var
a: array of Extended;
n, i, c: Integer;
x: Extended;
begin
Write ('Размерность массива = ');
ReadLn (n);
SetLength (a, n);
Randomize;
for i := Low (a) to High (a) do begin
a [i] := (Random (2001) - 1000) / 1000;
Write (a [i] :7 :3);
end;
x := 1;
c := 1;
WriteLn;
for i := Low (a) to High (a) do begin
if a [i] > 0 then begin
Write (a [i] :7 :3);
x := x * a [i];
Inc (c);
end;
end;
WriteLn;
WriteLn ('Среднее геометрическое = ', Power (x, 1/c) :20 :15);
ReadLn;
end.