Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit2;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
- type
- TForm2 = class(TForm)
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- Edit5: TEdit;
- Edit6: TEdit;
- Edit7: TEdit;
- Edit8: TEdit;
- Label9: TLabel;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form2: TForm2;
- x1 , x2 ,x3 , y1 , y2 ,y3 , s: real;
- implementation
- function f(x: real) : real ;
- begin
- f:= sin(x) / cos(x);
- end;
- function calculateLength(x1, y1, x2, y2:real):real;
- begin
- calculateLength := sqrt( sqr(x2 - x1) + sqr(y2 - y1) );
- end;
- //обчислення півпериметра
- function calculateHalfOfPerimeter(l1, l2, l3:real):real;
- begin
- calculateHalfOfPerimeter := (l1 + l2 + l3) / 2;
- end;
- //обчислення площі
- function calculateSquare(x1, y1, x2, y2, x3, y3:real):real;
- var p, l1, l2, l3: real;
- begin
- l1 := calculateLength(x1, y1, x2, y2);
- l2 := calculateLength(x2, y2, x3, y3);
- l3 := calculateLength(x1, y1, x3, y3);
- p := calculateHalfOfPerimeter(l1, l2, l3);
- calculateSquare := sqrt( p * (p - l1) * (p - l2) * (p - l3) );
- end;
- function maxFunction1(x : real ; y: real ) : real ;
- begin
- maxFunction1 := sin(x + y) ;
- end;
- function maxFunction2( z: real ) : real ;
- begin
- maxFunction2 := sin(10 - 2*z) / cos(10 - 2*z) ;
- end;
- function maxFunction3( y: real ) : real ;
- begin
- maxFunction3 := 6* y* y* y;
- end;
- {$R *.dfm}
- procedure TForm2.Button1Click(Sender: TObject);
- var y , x : real ;
- begin
- x:= StrToFloat(edit1.Text);
- edit2.Text:= FloatToStr(f(x));
- end;
- procedure TForm2.Button2Click(Sender: TObject);
- var x, y ,z , max1 , max2, max3 : real ;
- begin
- x:= StrToFloat(edit3.Text);
- y:= StrToFloat(edit4.Text);
- z:= StrToFloat(edit5.Text);
- max1 := maxFunction1(x , y);
- max2 := maxFunction2(z);
- max3 := maxFunction3(y);
- if(( max1 > max2 ) and(max1 > max3)) then
- begin
- edit6.Text:= FloatToStr(max1);
- end;
- if(( max2 > max1 ) and(max2 > max3)) then
- begin
- edit6.Text:= FloatToStr(max2);
- end;
- if(( max3 > max1 ) and(max3 > max2)) then
- begin
- edit6.Text:= FloatToStr(max3);
- end;
- end;
- procedure TForm2.Button3Click(Sender: TObject);
- var xt , yt , st1 , st2 , st3 , e, st: real ;
- begin
- xt:= StrToFloat(edit7.Text);
- yt:= StrToFloat(edit8.Text);
- x1:= -1 ;
- x2 := 1 ;
- x3 :=1;
- y1 := 1 ;
- y2 := 1;
- y3:= -1 ;
- S := calculateSquare(x1, y1, x2, y2, x3, y3);
- //площа малих трикутників
- St1 := calculateSquare(xt, yt, x1, y1, x3, y3);
- St2 := calculateSquare(x2, y2, xt, yt, x3, y3);
- St3 := calculateSquare(x1, y1, x2, y2, xt, yt);
- //сума площ малих трикутників
- St := St1 + St2 + St3;
- e := 0.0001;
- if ( (xt = x1) and (yt = y1) )
- or ( (xt = x2) and (yt = y2) )
- or ( (xt = x3) and (yt = y3) ) then //якщо на куті
- begin
- Label9.Caption:='Point is on kut';
- end
- else if (St1<e)
- or (St2<e)
- or (St3<e) then //якщо на стороні
- begin
- Label9.Caption :='Point is on one of the sides';
- end
- else if (St + e >= S) and (St - e <= S) then //якщо просто всередині
- begin
- Label9.Caption :='Point is inside triangle';
- end
- else
- begin
- label9.Caption :='OUT OF TRIANGLE'; //якщо поза трикутником
- end;
- end;
- procedure TForm2.Button4Click(Sender: TObject);
- begin
- edit1.Text := '';
- edit2.Text := '';
- edit3.Text := '';
- edit4.Text := '';
- edit5.Text := '';
- edit6.Text := '';
- edit7.Text := '';
- edit8.Text := '';
- end;
- procedure TForm2.Button5Click(Sender: TObject);
- begin
- Close;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement