1)
const N = 4;
var i, j, count, sum, un_count, un_sum:integer;
a:array[1..N, 1..N] of integer;
begin
count:=0;
sum:=0;
un_count:=0;
un_sum:=0;
for i:=1 to N do
for j:= 1 to N do a[i, j]:=random(99)-99;
for j:= 1 to N do begin
if (a[i,j] < 0) then begin
un_sum:= un_sum + a[i, j];
un_count:= un_count + 1;
end
else begin
sum:= sum + a[i, j];
count:= count + 1;
end;
writeln('Среднее положительное: ', sum/count);
write('Среднее отрицательное: ', un_sum/un_count);
end.
2)
var i, j, count, sum:integer;
for i:= 1 to N do
for j:= 1 to N do
a[i, j]:= random (99);
if (a[i, j] mod 10 = a[i, j] div 10) then
if (count = N) and (j = N) then write('Ряд ', i, 'парный.') else count:= 0;
1)
const N = 4;
var i, j, count, sum, un_count, un_sum:integer;
a:array[1..N, 1..N] of integer;
begin
count:=0;
sum:=0;
un_count:=0;
un_sum:=0;
for i:=1 to N do
for j:= 1 to N do a[i, j]:=random(99)-99;
for i:=1 to N do
for j:= 1 to N do begin
if (a[i,j] < 0) then begin
un_sum:= un_sum + a[i, j];
un_count:= un_count + 1;
end
else begin
sum:= sum + a[i, j];
count:= count + 1;
end;
end;
writeln('Среднее положительное: ', sum/count);
write('Среднее отрицательное: ', un_sum/un_count);
end.
2)
const N = 4;
var i, j, count, sum:integer;
a:array[1..N, 1..N] of integer;
begin
for i:= 1 to N do
for j:= 1 to N do
a[i, j]:= random (99);
for i:=1 to N do
for j:= 1 to N do begin
if (a[i, j] mod 10 = a[i, j] div 10) then
count:= count + 1;
if (count = N) and (j = N) then write('Ряд ', i, 'парный.') else count:= 0;
end;
end.