var a: array[1..100, 1..100] of real; max, min: real; sum, product: real; i, j, m, n, k: integer;
begin {ввод матрицы} if handsfree then begin n := random(20) + 2; m := random(20) + 2; end else begin write('n, m ='); readln(n, m); end;
writeln('Данные матрицы:'); for i := 1 to m do begin for j := 1 to n do if handsfree then begin a[i, j] := random(100) - 50; write(a[i, j]:4, ' ') end else read(a[i, j]); writeln; end;
{минимумы и максимумы} max := a[1, 1]; min := a[1, 1]; for i := 1 to m do for j := 1 to n do begin if max < a[i, j] then max := a[i, j]; if min > a[i, j] then min := a[i, j]; end; writeln('max = ', max); writeln('min = ', min);
{сумма, произведение, пр. агригаты} sum := 0; product := 1; for i := 1 to m do for j := 1 to n do if a[i, j] <> 0 then {если нужен фильтр} begin sum := sum + a[i, j]; product := product * a[i, j]; k := k + 1; end; writeln('sum = ', sum); writeln('product = ', product); writeln('average = ', sum / (n * m)); writeln('average (selected) = ', sum / k); end.
const
handsfree = true;
var
a: array[1..100, 1..100] of real;
max, min: real;
sum, product: real;
i, j, m, n, k: integer;
begin
{ввод матрицы}
if handsfree then begin
n := random(20) + 2;
m := random(20) + 2;
end
else begin
write('n, m =');
readln(n, m);
end;
writeln('Данные матрицы:');
for i := 1 to m do
begin
for j := 1 to n do
if handsfree then begin
a[i, j] := random(100) - 50;
write(a[i, j]:4, ' ')
end
else
read(a[i, j]);
writeln;
end;
{минимумы и максимумы}
max := a[1, 1];
min := a[1, 1];
for i := 1 to m do
for j := 1 to n do
begin
if max < a[i, j] then max := a[i, j];
if min > a[i, j] then min := a[i, j];
end;
writeln('max = ', max);
writeln('min = ', min);
{сумма, произведение, пр. агригаты}
sum := 0;
product := 1;
for i := 1 to m do
for j := 1 to n do
if a[i, j] <> 0 then {если нужен фильтр}
begin
sum := sum + a[i, j];
product := product * a[i, j];
k := k + 1;
end;
writeln('sum = ', sum);
writeln('product = ', product);
writeln('average = ', sum / (n * m));
writeln('average (selected) = ', sum / k);
end.