Const n=5; var t:array[1..n,1..n] of integer; i,j,p,k:integer; begin Randomize; writeln('Исходный массив:'); for i:=1 to n do begin for j:=1 to n do begin t[i,j]:=random(50); write(t[i,j]:4); end; writeln; end; p:=1; k:=0; for i:=1 to n do begin if t[i,i] mod 5 = 0 then p:=p*t[i,i]; if t[i,n-i+1] mod 2 = 0 then k:=k+1; end; writeln('p = ',p,' k = ',k); end.
var
t:array[1..n,1..n] of integer;
i,j,p,k:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to n do
begin
t[i,j]:=random(50);
write(t[i,j]:4);
end;
writeln;
end;
p:=1; k:=0;
for i:=1 to n do
begin
if t[i,i] mod 5 = 0 then p:=p*t[i,i];
if t[i,n-i+1] mod 2 = 0 then k:=k+1;
end;
writeln('p = ',p,' k = ',k);
end.
Пример:
Исходный массив:
30 16 33 25 4
23 2 11 14 45
11 29 22 48 6
36 21 35 37 4
27 14 44 13 29
p = 30 k = 3