Advertisement
Guest User

herota

a guest
Dec 12th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.79 KB | None | 0 0
  1. unit Unit8;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ExtCtrls, OleCtnrs, AxCtrls, OleCtrls, VCF1;
  8.  
  9. type
  10.   matr = array [1..4,1..4] of real;
  11.   TForm1 = class(TForm)
  12.     Label1: TLabel;
  13.     Label2: TLabel;
  14.     Panel2: TPanel;
  15.     Button1: TButton;
  16.     Button3: TButton;
  17.     Button2: TButton;
  18.     OleContainer1: TOleContainer;
  19.     F1Book1: TF1Book;
  20.     F1Book2: TF1Book;
  21.     procedure Button1Click(Sender: TObject);
  22.     procedure Button3Click(Sender: TObject);
  23.     procedure Button2Click(Sender: TObject);
  24.   private
  25.     { Private declarations }
  26.   public
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.   a : matr;
  33. implementation
  34.  
  35. {$R *.dfm}
  36.  
  37. procedure TForm1.Button3Click(Sender: TObject);
  38. begin
  39.     close;
  40. end;
  41.  
  42. procedure TForm1.Button1Click(Sender: TObject);
  43.          var t : textfile; i,j : integer;
  44. begin
  45.       assignfile(t,'Massive.txt');
  46.       reset (t);
  47.       for i := 1 to 4 do
  48.       for j:=1 to 4 do
  49.       begin
  50.       read (t,a[i,j]);
  51.       F1Book1.NumberRC[i,j] := a[i,j];
  52.       end;
  53. end;
  54.  
  55. function sum (g:matr;i : integer) : real;
  56. var
  57. j : integer;
  58. s : real;
  59. begin
  60. s :=0;
  61. for j:=1 to 4 do
  62. s:= g[i,j];
  63. sum := s;
  64. end;
  65.  
  66. procedure stroki (g:matr);
  67. var
  68. i,j,k,l : integer;
  69. s,u :real;
  70. q : array [1..4] of real;
  71. begin
  72. for i:=1 to 4 do
  73. q[i]:=sum(a,i);
  74.  
  75.   k:=4;
  76.   while k >1 do
  77.    begin
  78.    l:=1;
  79.    for i:=2 to k do
  80.     if q[i] > q[l] then
  81.       l:=i;
  82.    for j:=1 to 4 do
  83.      begin
  84.      s:=g[l,j];
  85.      g[l,j] := g[k,j];
  86.      g[k,j] := s;
  87.      end;
  88.    k:= k-1;
  89.    end;
  90.    for i:=1 to 4 do
  91.     for j:=1 to 4 do
  92.      Form1.F1Book2.NumberRC[i,j]:=g[i,j];
  93. end;
  94.  
  95.  
  96. procedure TForm1.Button2Click(Sender: TObject);
  97.  var i, j : integer;
  98. begin
  99. stroki(a);
  100. end;
  101. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement