Const m = 3; n = 3; var a: array[1..m, 1..n] of integer; i,j,max3:integer; begin max3:=-MaxInt; for i:=1 to m do begin for j:=1 to n do begin write('A[',i,',',j,']= '); readln (a[i,j]); if (a[i,j] mod 3 = 0)and (max3<a[i,j]) then max3:=a[i,j]; end; end; writeln('Максимальное кратное трем ',max3); end.
Answers & Comments
Verified answer
Const m = 3;n = 3;
var a: array[1..m, 1..n] of integer;
i,j,max3:integer;
begin
max3:=-MaxInt;
for i:=1 to m do begin
for j:=1 to n do begin
write('A[',i,',',j,']= ');
readln (a[i,j]);
if (a[i,j] mod 3 = 0)and (max3<a[i,j]) then
max3:=a[i,j];
end;
end;
writeln('Максимальное кратное трем ',max3);
end.
Тестовое решение:
A[1,1]= -15
A[1,2]= 9
A[1,3]= 3
A[2,1]= 7
A[2,2]= -21
A[2,3]= 21
A[3,1]= 15
A[3,2]= -9
A[3,3]= 9
Максимальное кратное трем 21