V
V
Victor482021-06-10 13:14:54
Pascal
Victor48, 2021-06-10 13:14:54

In each row, the largest element is interchanged with the element of the main diagonal, after the permutation of the elements is the resulting two-dimensional?

It is necessary that in each line the largest element be interchanged with the element of the main
diagonal, after rearranging the elements, display the resulting two-dimensional array on the
screen;
Managed to do so far

var 
  a: array[1..5,1..5] of integer;
  n,m,i,j,k :byte;
  max,min,jmax :integer;
  begin
  writeln('Введите количество строк n и столбцов m(n<=5,m<=5)');
  readln(n,m);
  writeln('Исходный двухмерный массив');
  for i := 1 to n do
  begin
    for j:= 1 to n do
    begin
      a[i,j]:= random(20)+1;
      write(a[i,j]:4,' ');
    end;
    writeln;
    end;
    max := a[1,1];
    for i := 1 to n do
    begin
      for j:= 1 to m do
        if a[i,j] > max then
          max := a[i,j];
    end;
    for i := 1 to n do
    begin
      max :=a[i,1];
      jmax := 1;
      for j := 1 to m do
        if a[i,j] > max then begin
          max:= a[i,j];
        jmax := j;
        end;
        writeln('max элемент ',i,' строки находится в ', jmax,' столбце= ',max);
        
      end;
  end.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question