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;
if a [i] > 0 then begin
x := x * a [i];
Inc (c);
WriteLn ('Среднее геометрическое = ', Power (x, 1/c) :20 :15);
ReadLn;
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.