Программа формирует новый массив со смещением в лево
Program sector; const n=10; var a,b:array [1..n,1..n] of integer; z:real; i,j,k: byte; begin randomize; for i:=1 to n do begin for j:=1 to n do begin a[i,j]:=random (40); a[i,j]:=a[i,j]-20; write(a[i,j]:4); end; writeln; end; z:=0; for i:=1 to n do for j:=1 to i do z:=z+a[i,j]; z:=z/(n*n); writeln('srednee = ',z); for i:=1 to n do begin k:=1; for j:=1 to n do if a[i,j] > z then begin b[i,k]:=a[i,j]; write(b[i,k]:4); k:=k+1; end; writeln; end; readln; end.
Программа формирует новый массив со смещением в лево
Program sector;
const
n=10;
var
a,b:array [1..n,1..n] of integer;
z:real;
i,j,k: byte;
begin
randomize;
for i:=1 to n do begin
for j:=1 to n do begin
a[i,j]:=random (40);
a[i,j]:=a[i,j]-20;
write(a[i,j]:4);
end;
writeln;
end;
z:=0;
for i:=1 to n do
for j:=1 to i do
z:=z+a[i,j];
z:=z/(n*n);
writeln('srednee = ',z);
for i:=1 to n do begin
k:=1;
for j:=1 to n do
if a[i,j] > z then begin
b[i,k]:=a[i,j];
write(b[i,k]:4);
k:=k+1;
end;
writeln;
end;
readln;
end.
var i, j: integer;
var s: real;
var m: array[1..20] of integer;
var n: array[1..20] of integer;
{ формируем массив и заодно вычисляем сумму элементов }
for i := 1 to 20 do begin
m[i] := random(1000);
s := s + m[i];
end;
{ печать массива }
for i := 1 to 20 do begin
writeln(m[i]);
end;
writeln('');
{ среднее арифметическое }
s := s / 20;
writeln(s);
j := 0;
for i := 1 to 20 do begin
if m[i] > s then begin
j := j + 1;
n[j] := m[i];
end;
end;
writeln('');
for i := 1 to j do begin
writeln(n[i]);
end;
end.