Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.24 KB | None | 0 0
  1.  
  2. procedure ChangeMatrixRow(IndexI, IndexN, MyMatrixSize : integer);
  3. var
  4.     J, RowElement, SecRowEl : integer;
  5. begin
  6.     for J := 0 to MyMatrixSize do
  7.     begin
  8.         RowElement :=  Matrix[IndexI,J];
  9.         Matrix[IndexI,J] := Matrix[IndexN,J];
  10.         Matrix[IndexN,J] := RowElement;
  11.     end;
  12. end;
  13.  
  14.  
  15.  
  16.  
  17. procedure Sort( MyMatrixSize : integer) ;
  18. var
  19.     I, J, DiagonalElement, IndexI, IndexJ, N, M, K, PrevDiagEl  : integer;
  20. begin
  21.     M := 0;
  22.     N := 0;
  23.     PrevDiagEl := 0;
  24.     MyMatrixSize := MyMatrixSize - 1;
  25.     for I := 0 to MyMatrixSize-1 do
  26.     begin
  27.         DiagonalElement := Matrix[N,M];
  28.         K := M;
  29.         for J := 1 to MyMatrixSize  do
  30.         begin
  31.             DiagonalElement := Matrix[N,K];
  32.             if ((DiagonalElement > Matrix[i,j]) and (Matrix[i,j] >= PrevDiagEl))  then
  33.             begin
  34.                 ChangeMatrixRow(J, N, MyMatrixSize);
  35.             end;
  36.             inc(k);
  37.         end;
  38.         PrevDiagEl := Matrix[N,M];
  39.         Inc(M);
  40.         Inc(N);
  41.     end;
  42.     Writeln;
  43.     writeln('Результат: ');
  44.     for i := 0 to  MyMatrixSize   do
  45.     begin
  46.         writeln;
  47.         for j := 0 to MyMatrixSize  do
  48.             write(Matrix[i,j] : 4  );
  49.     end;
  50.      Readln;
  51.  
  52. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement