: , , . Tg(x), Ch(x) sin (x).
, , . DELPHI , , .. , . File Close All, .
File File New, . Unit Unit1. , , Unit Matfu;. , : Matfu.pas. , , DELPHI .
Project Add to Project... , . Uses - MatFu. , .
(.7.1).
.7.1
.
:
Unit Matfu;
Interface
Function Tg(x: extended): extended;
//
Function Ch(x: extended): extended;
//
Function Sin2(x: extended): extended; //
//
Iplementation
Function Tg;
begin
Result:= sin(x)/cos(x);
End;
Function Ch;
begin
Result:= (exp(x)-exp(-x))/2;
End;
Function Sin2;
Begin
Result:= sqr(sin(x));
End;
End.
:
Unit Unit1;
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, MatFunc;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
RadioGroup1: TRadioGroup;
Procedure FormCreate(Sender: TObject);
Procedure Button1Click(Sender: TObject);
Procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
func = function(x:extended): extended;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text:= '0';
Edit2.Text:= '2';
Edit3.Text:= '0.2';
Memo1.Clear;
RadioGroup1.ItemIndex:= 0;
|
|
end;
procedure Tabl(f: func; xn, xk, h: extended);
var
x, y: extended;
begin
x:= xn;
Repeat
y:= f(x);
Form1.Memo1.Lines.Add('x=' + FloatToStrF(x,fffixed, 8,2)+
' y=' + FloatToStrF(y,fffixed, 8,2));
x:= x + h;
Until (x > xk);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
xn, xk, h: extended;
begin
xn:= StrToFloat(Edit1.Text);
xk:= StrToFloat(Edit2.Text);
h:= StrToFloat(Edit3.Text);
Case RadioGroup1.ItemIndex of
0: Tabl(tg, xn, xk, h);
1: Tabl(ch, xn, xk, h);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Halt
end;
end.