//1) var A: array [1..30] of integer; i: byte; mult: double; begin mult := 1; randomize; writeln('Сгенерированный массив.'); for i := 1 to 30 do begin A[i] := random(46)-15; if A[i] > 0 then mult := mult * A[i]; write(A[i], ' '); end; writeln; writeln('Произведение положительных элементов = ', mult); end. //
//2) var A: array [1..40] of integer; i: byte; count: byte; begin count := 0; randomize; writeln('Сгенерированный массив.'); for i := 1 to 40 do begin A[i] := random(31)-20; if A[i] mod 3 = 0 then count := count + 1; write(A[i], ' '); end; writeln; writeln('Количество элементов кратных трем = ', count); end. //
//3) var A: array [1..40] of integer; i: byte; count: byte; sum: integer; begin count := 0; sum := 0; randomize; writeln('Сгенерированный массив.'); for i := 1 to 40 do begin A[i] := random(61)-30; if A[i] < 0 then begin count := count + 1; sum := sum + A[i]; end; write(A[i], ' '); end; writeln; writeln('Среднее арифметическое отрицательных эл. =',(sum/count):4:4); end. //
1. uses crt; const n=20; var i,cp1,cn1:integer; p,cp,cn:real; z:array[1..n] of integer; begin randomize; for i:=1 to n do begin z[i]:=random(20,-20); if z[i]>=0 then begin cp:=cp+z[i]; cp1:=cp1+1; end else begin cn:=cp+z[i]; cn1:=cn1+1; end; cp:=cp/cp1; cn:=cn/cn1; end; if cp>cn then p:=cp+cn else p:=cp*cn; for i:=1 to n do write(z[i],' '); writeln(#13#10,cp:5:2,' ',cn:5:2,' ',p:5:2); end. 2. uses crt; const n=15;m=4; var i,j,k,flag,count:integer; a:array[1..n,1..m] of integer; temp:array[1..100] of integer; b:array[1..100,1..m] of integer; begin randomize; k:=1; count:=0; for i:=1 to n do begin flag:=1; for j:=1 to m do begin a[i,j]:=random(51,1); if (a[i,j]<10) or (a[i,j]>40) then flag:=0 end; if flag=1 then begin temp[k]:=i; count:=count+1; k:=k+1; end; end; for i:=1 to count do for j:=1 to m do b[i,j]:=a[temp[i],j]; writeln('Массив A:'); for i:=1 to n do begin for j:=1 to m do write(a[i,j],' '); write(#13#10); end; if count=0 then writeln('Нет подходящих строк.') else begin writeln(#13#10,'Массив B:'); for i:=1 to count do begin for j:=1 to m do write(b[i,j],' '); write(#13#10); end; end; end.
//1)
var
A: array [1..30] of integer;
i: byte; mult: double;
begin
mult := 1;
randomize;
writeln('Сгенерированный массив.');
for i := 1 to 30 do
begin
A[i] := random(46)-15;
if A[i] > 0 then mult := mult * A[i];
write(A[i], ' ');
end;
writeln;
writeln('Произведение положительных элементов = ', mult);
end.
//
//2)
var
A: array [1..40] of integer;
i: byte; count: byte;
begin
count := 0;
randomize;
writeln('Сгенерированный массив.');
for i := 1 to 40 do
begin
A[i] := random(31)-20;
if A[i] mod 3 = 0 then count := count + 1;
write(A[i], ' ');
end;
writeln;
writeln('Количество элементов кратных трем = ', count);
end.
//
//3)
var
A: array [1..40] of integer;
i: byte; count: byte; sum: integer;
begin
count := 0; sum := 0;
randomize;
writeln('Сгенерированный массив.');
for i := 1 to 40 do
begin
A[i] := random(61)-30;
if A[i] < 0 then
begin
count := count + 1;
sum := sum + A[i];
end;
write(A[i], ' ');
end;
writeln;
writeln('Среднее арифметическое отрицательных эл. =',(sum/count):4:4);
end.
//
uses crt;
const n=20;
var i,cp1,cn1:integer;
p,cp,cn:real;
z:array[1..n] of integer;
begin
randomize;
for i:=1 to n do
begin
z[i]:=random(20,-20);
if z[i]>=0 then
begin
cp:=cp+z[i];
cp1:=cp1+1;
end
else
begin
cn:=cp+z[i];
cn1:=cn1+1;
end;
cp:=cp/cp1;
cn:=cn/cn1;
end;
if cp>cn then
p:=cp+cn
else
p:=cp*cn;
for i:=1 to n do
write(z[i],' ');
writeln(#13#10,cp:5:2,' ',cn:5:2,' ',p:5:2);
end.
2.
uses crt;
const n=15;m=4;
var i,j,k,flag,count:integer;
a:array[1..n,1..m] of integer;
temp:array[1..100] of integer;
b:array[1..100,1..m] of integer;
begin
randomize;
k:=1;
count:=0;
for i:=1 to n do
begin
flag:=1;
for j:=1 to m do
begin
a[i,j]:=random(51,1);
if (a[i,j]<10) or (a[i,j]>40) then
flag:=0
end;
if flag=1 then
begin
temp[k]:=i;
count:=count+1;
k:=k+1;
end;
end;
for i:=1 to count do
for j:=1 to m do
b[i,j]:=a[temp[i],j];
writeln('Массив A:');
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j],' ');
write(#13#10);
end;
if count=0 then
writeln('Нет подходящих строк.')
else
begin
writeln(#13#10,'Массив B:');
for i:=1 to count do
begin
for j:=1 to m do
write(b[i,j],' ');
write(#13#10);
end;
end;
end.