Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
- Grids;
- type
- Matr = Array[1..3,1..3] of Real;
- Vec = Array[1..3] of Real;
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- StringGrid1: TStringGrid;
- StringGrid2: TStringGrid;
- StringGrid3: TStringGrid;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- CLOSE
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- Var A : Matr;
- b: Vec;
- det,detx,dety,detz,x,y,z,eps:real;
- i, j, N: Integer;
- begin
- N := 3;
- eps :=0.0001;
- For i:=1 to N do
- For j:=1 to N do
- Begin
- a[i,j] := StrToFloat(StringGrid1.Cells[j - 1,i - 1]);
- b[j] := StrToFloat(StringGrid2.Cells[0,j - 1]);
- End;
- Det:=A[1,1]*A[2,2]*A[3,3]+A[2,1]*A[1,3]*A[3,2]+A[1,2]*A[2,3]*A[3,1]-A[3,1]*A[2,2]*A[1,3]-A[1,1]*A[3,2]*A[2,3]-A[2,1]*A[1,2]*A[3,3];
- if abs(Det)<eps then
- begin
- ShowMessage('rozvjazkiv nemaje');
- close
- end
- else
- if abs(det)>0 then
- begin
- Detx:=b[1]*A[2,2]*A[3,3]+b[2]*A[1,3]*A[3,2]+A[1,2]*A[2,3]*b[3]-b[3]*A[2,2]*A[1,3]-b[1]*A[3,2]*A[2,3]-b[2]*A[1,2]*A[3,3];
- Dety:=A[1,1]*b[2]*A[3,3]+A[2,1]*A[1,3]*b[3]+b[1]*A[2,3]*A[3,1]-A[3,1]*b[2]*A[1,3]-A[1,1]*b[3]*A[2,3]-A[2,1]*b[1]*A[3,3];
- Detz:=A[1,1]*A[2,2]*b[3]+A[2,1]*b[1]*A[3,2]+A[1,2]*b[2]*A[3,1]-A[3,1]*A[2,2]*b[1]-A[1,1]*A[3,2]*b[2]-A[2,1]*A[1,2]*b[3];
- x:=Detx/Det;
- y:=Dety/Det;
- z:=Detz/Det;
- StringGrid3.Cells[0,0]:=floattostr(x);
- StringGrid3.Cells[0,1]:=floattostr(y);
- StringGrid3.Cells[0,2]:=floattostr(z);
- end;
- end;
- end.
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement