Const n=5; m=7; var x:array[1..n,1..m] of integer; i,j,s:integer; begin Randomize; Writeln('Исходный массив'); for i:=1 to n do begin for j:=1 to n do begin x[i,j]:=Random(100); Write(x[i,j]:3) end; Writeln end; s:=0; i:=1; while i<=n do begin for j:=1 to m do if x[i,j] mod 2=0 then s:=s+x[i,j]; i:=i+2 end; Writeln('s=',s) end.
n=5;
m=7;
var
x:array[1..n,1..m] of integer;
i,j,s:integer;
begin
Randomize;
Writeln('Исходный массив');
for i:=1 to n do
begin
for j:=1 to n do
begin
x[i,j]:=Random(100);
Write(x[i,j]:3)
end;
Writeln
end;
s:=0;
i:=1;
while i<=n do
begin
for j:=1 to m do if x[i,j] mod 2=0 then s:=s+x[i,j];
i:=i+2
end;
Writeln('s=',s)
end.
Контрольное решение
Исходный массив
77 38 20 72 25
22 5 99 53 21
74 8 80 31 28
35 24 28 79 29
21 25 51 71 56
s=376