R
R
Roma2017-03-21 14:03:05
Delphi
Roma, 2017-03-21 14:03:05

How to find the maximum element of a matrix on the main diagonal and below it?

How to find the maximum element of a matrix on the main diagonal and below it?
Matrix 5X5.
Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Fedoryan, 2017-03-21
@k4roma

On PascalABC.NET

program max_element;
var
  matrix: array[0..4, 0..4] of integer;
  i, j: integer;
  max: integer;
begin
  Randomize;
  // Заполнение матрицы
  for i := 0 to 4 do
    begin
      for j := 0 to 4 do
        matrix[i][j] := Random(10, 99);
      WriteLn(matrix[i]);
    end;
  
  i := 0;
  j := 0;
  max := matrix[i][j];
  for j := 0 to 4 do
    for i := j to 4 do
      if max < matrix[i][j] then
        max := matrix[i][j];
  
  WriteLn(max);
end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question