![]() |
|
#1
|
|||
|
|||
![]() Есть код программы ,не получается оформить в виде процедуры помещенной в библиотечный модуль ..
Код:
unit obra; // код модуля interface type kol= integer; obr=array[0..10, 0..10] of real; b= array[0..10, 0..10] of real; procedure _obra(z:obr;r:b;kol:integer); implementation procedure _obra(z:obr;r:b;kol:integer); var k, i, j: integer; begin for k:=0 to kol-1 do begin for i:=0 to kol - 1 do for j:=0 to kol - 1 do begin if (i=k) and (j=k) then z[i,j] := 1/r[i,j]; if (i=k) and (j<>k) then z[i,j] := -r[i,j]/r[k,k]; if (i<>k) and (j=k) then z[i,j] := r[i,k]/r[k,k]; if (i<>k) and (j<>k) then z[i,j] := r[i,j] - r[k,j] * r[i,k]/r[k,k]; end; for i:= 0 to kol - 1 do for j:= 0 to kol - 1 do r[i, j]:= z[i, j]; end; end; end. Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, Grids,Obra; type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; StringGrid1: TStringGrid; Button1: TButton; BitBtn1: TBitBtn; Button2: TButton; StringGrid2: TStringGrid; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var i, j,kol: integer; i1, j1: integer; begin i1:= 1; j1:= 1; for i:= 0 to kol - 1 do for j:= 0 to kol - 1 do begin i1:= i; j1:= j; _obra(z,r,kol); z[i, j]:= StrToFloat(StringGrid1.Cells[j, i]); end; end; procedure TForm1.FormCreate(Sender: TObject); var i,j,n,d:integer; begin d:=strtoint(edit1.Text); stringgrid1.RowCount:=d+1; stringgrid1.ColCount:=d+1; stringgrid1.cells[0,0]:='A'; for i:=1 to d do stringgrid1.cells[i,0]:='i='+inttostr(i); for j:=1 to d do stringgrid1.cells[0,j]:='j='+inttostr(j); end; procedure TForm1.Button2Click(Sender: TObject); var i,j,n:integer; begin n:=strtoint(edit1.text); randomize; for i:=1 to n do for j:=1 to n do stringgrid1.Cells[i,j]:=inttostr(random(10)); end; end. Последний раз редактировалось qpmr, 04.05.2012 в 09:04. |