Двумерный массив А (4;4) найдите максимальный элемент
Answers & Comments
Pashq4
Const N = 4; var a: array[1..N,1..N] of integer; i,j,k,z: integer; begin for i := 1 to N do begin for j := 1 to N do begin a[i,j]:=random(10); write(a[i,j]:5); end; writeln(); end; writeln(); k:=1; z:=1; for i:=1 to N do for j:=1 to N do if a[i,j] > a[k,z] then begin k:=i; z:=j; end; writeln('Максимальный элемент: ',a[ k, z ]); end.
Answers & Comments
var a: array[1..N,1..N] of integer;
i,j,k,z: integer;
begin for i := 1 to N do begin
for j := 1 to N do
begin
a[i,j]:=random(10);
write(a[i,j]:5);
end;
writeln();
end;
writeln();
k:=1;
z:=1;
for i:=1 to N do for j:=1 to N do if a[i,j] > a[k,z] then
begin
k:=i;
z:=j;
end;
writeln('Максимальный элемент: ',a[ k, z ]);
end.