Дан массив 4*4 случайных, целых чисел от -50 до 50. Вывести максимальное число каждой строки. Паскаль АВС
Answers & Comments
cccc1808
const n = 4; var a : array [1..n,1..n] of integer; i,j,max : integer; begin randomize; for i := 1 to n do for j := 1 to n do a[i,j] := -50 + random (101); for i := 1 to n do begin max := a[i,1]; for j := 2 to n do if a[i,j] > max then max := a[i,j]; writeln (max); end; end.
0 votes Thanks 0
Hasl1337
Var i, j: integer; a: array[1..4, 1..4] of integer; b: array[1..4] of integer; begin for i := 1 to 4 do begin for j := 1 to 4 do begin a[i, j] := random(101) - 50; write(a[i, j]:5); if(a[i, j] > b[i]) then b[i] := a[i, j]; end; writeln; end;
for i := 1 to 4 do write(#10, 'Макс элемент ', i, ' строки: ', b[i]); end.
Answers & Comments
n = 4;
var
a : array [1..n,1..n] of integer;
i,j,max : integer;
begin
randomize;
for i := 1 to n do
for j := 1 to n do
a[i,j] := -50 + random (101);
for i := 1 to n do
begin
max := a[i,1];
for j := 2 to n do
if a[i,j] > max then
max := a[i,j];
writeln (max);
end;
end.
a: array[1..4, 1..4] of integer;
b: array[1..4] of integer;
begin
for i := 1 to 4 do begin
for j := 1 to 4 do begin
a[i, j] := random(101) - 50;
write(a[i, j]:5);
if(a[i, j] > b[i]) then b[i] := a[i, j];
end;
writeln;
end;
for i := 1 to 4 do write(#10, 'Макс элемент ', i, ' строки: ', b[i]);
end.