Найти среднее арифметическое отрицательных элементов матрицы t(9,6) — Pascal(Паскаль)

uses crt;

const
  lim = 100;

var
  t: array [1 .. 9, 1 .. 6] of real;
  i, j, count: byte;
  sr: real;

begin
  ClrScr;
  randomize;
  writeln('Sformirovannaia matrica:');
  count := 0;
  sr := 0;
  for i := 1 to 9 do
  begin
    for j := 1 to 6 do
    begin
      t[i, j] := -lim + random(2 * lim + 1) + Trunc(random * 10) / 10;
      write(t[i, j]:7:2);
      if t[i, j] < 0 then
      begin
        inc(count);
        sr := sr + t[i, j];
      end;
    end;
    writeln;
  end;
  writeln;
  writeln('Sum=', sr:6:2);
  writeln('Count=', count);
  sr := sr / count;
  writeln('Sr=', sr:6:2);
  readkey;

end.

Leave a Comment

2 + 2 =