Const n=3; m=4; var a:array[1..n,1..m] of integer; b:array[1..n*m] of integer; i,j,k:integer; sr:real; begin Randomize; writeln('Исходный массив:'); for i:=1 to n do begin for j:=1 to m do begin a[i,j]:=random(100); write(a[i,j]:4); end; writeln; end; sr:=0; for i:=1 to n do for j:=1 to m do sr:=sr+a[i,j]; sr:=sr/(n*m); writeln('sr = ',sr); k:=0; for i:=1 to n do for j:=1 to m do if a[i,j]<sr then begin k:=k+1; b[k]:=a[i,j]; end; writeln('Полученный массив:'); for i:=1 to k do write(b[i]:4); writeln; end.
var
a:array[1..n,1..m] of integer;
b:array[1..n*m] of integer;
i,j,k:integer; sr:real;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to m do
begin
a[i,j]:=random(100);
write(a[i,j]:4);
end;
writeln;
end;
sr:=0;
for i:=1 to n do
for j:=1 to m do sr:=sr+a[i,j];
sr:=sr/(n*m);
writeln('sr = ',sr);
k:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]<sr then begin k:=k+1; b[k]:=a[i,j]; end;
writeln('Полученный массив:');
for i:=1 to k do write(b[i]:4);
writeln;
end.
Пример:
Исходный массив:
72 51 6 83
51 68 61 25
22 57 76 79
sr = 54.25
Полученный массив:
51 6 51 25 22