Var ma:array[1..n,1..n] of real; i,j:integer; r:real; begin randomize; r:=1; writeln('Matrix:'); for i:=1 to n do begin; writeln; for j:=1 to n do begin; ma[i,j]:=random(1,10); if j mod 2<>0 then r:=r*ma[i,j]; write(ma[i,j]:4); end; end; writeln; writeln('Res=',r); end.
Пример работы кода: Matrix: 5 3 3 2 2 5 10 2 4 Res=6000
const N = 3; var a: array[1..N, 1..N] of real; i, j: integer; pr: real; begin pr:=1; for i:=1 to N do for j:=1 to N do readln(a[i, j]); for i:=1 to N do for j:=1 to N do If j mod 2 <> 0 then pr:=pr*a[i, j]; writeln(pr); end.
Answers & Comments
Verified answer
//Pascal ABC.NET v3.1 сборка 1172Const
n=3;
Var
ma:array[1..n,1..n] of real;
i,j:integer;
r:real;
begin
randomize;
r:=1;
writeln('Matrix:');
for i:=1 to n do
begin;
writeln;
for j:=1 to n do
begin;
ma[i,j]:=random(1,10);
if j mod 2<>0 then r:=r*ma[i,j];
write(ma[i,j]:4);
end;
end;
writeln;
writeln('Res=',r);
end.
Пример работы кода:
Matrix:
5 3 3
2 2 5
10 2 4
Res=6000
const N = 3;
var a: array[1..N, 1..N] of real;
i, j: integer;
pr: real;
begin
pr:=1;
for i:=1 to N do
for j:=1 to N do
readln(a[i, j]);
for i:=1 to N do
for j:=1 to N do
If j mod 2 <> 0 then
pr:=pr*a[i, j];
writeln(pr);
end.