Const n=6; var d:array[1..n,1..n] of integer; i,j,max:integer; begin Randomize; for i:=1 to n do begin for j:=1 to n do begin d[i,j]:=random(20); write(d[i,j]:4); end; writeln; end; max:=d[2,1]; for i:=3 to n do for j:=1 to i-1 do if d[i,j]>max then max:=d[i,j]; writeln('max=',max); end.
Answers & Comments
Verified answer
Const n=6;var d:array[1..n,1..n] of integer;
i,j,max:integer;
begin
Randomize;
for i:=1 to n do begin
for j:=1 to n do begin
d[i,j]:=random(20);
write(d[i,j]:4);
end;
writeln;
end;
max:=d[2,1];
for i:=3 to n do
for j:=1 to i-1 do
if d[i,j]>max then max:=d[i,j];
writeln('max=',max);
end.
Пример:
11 8 14 3 11 5
12 6 12 18 9 19
3 5 3 1 15 4
1 1 10 17 0 17
12 5 2 14 15 11
16 4 10 7 0 1
max=16