136 04 01 - ,
139 02 02 ,
139 02 03 ,
139 02 01
,
139 03 01 .
2011
1. DELPHI.
................................................................................... 5
1.1. Delphi ................................................ 5
1.2. Delphi............................................................................. 6
1.3. ........................................................................ 7
1.3.1. ..................................................................................... 7
1.3.2. ..................................................................... 7
1.3.3. (Edit) .............................................................. 8
1.3.4. (Label) ................................................................... 8
1.3.5. (Memo)................................ 8
1.3.6. Close.......................................................................... 9
1.3.7.
(FormCreate) ......................................................................................................... 9
1.3.8.
(ButtonClick) .......................................................................................................... 9
1.3.9. ............................................................... 10
1.4. .............................................................................. 12
2. DELPHI.
.............................................................. 14
2.1. ........................................................................................ 14
2.2. if case Object Pascal....................................................... 15
2.3. Delphi................................................................................. 15
2.4. ...................................................................... 15
2.4.1. Co ....................................................................................... 16
2.4.2. heckBox.......................................................... 16
2.4.3. RadioGroup...................................................... 17
2.5. .............................................................................. 18
3. DELPHI.
............................ 20
3.1. Delphi ........................................................... 20
3.2. repeat, while, for..................................... 21
3.3. ...................................................................... 22
3.4. .............................................................................. 24
4. .
..................... 27
4.1. ......................................................... 27
4.2. ShowMessage MessageDlg................................ 29
4.3. ......................................................................................... 30
4.4. StringGrid..................................................................................... 30
4.5. ...................................................................... 31
4.6. .............................................................................. 35
2
5.
....................................................................37
5.1. ...........................................................37
5.2. ...............................................................................37
6.
.................................................................................................................39
6.1. .................................................................................39
6.2. .............................................................................................39
6.3. ......................................................................................40
6.4. ......................................................................40
6.5. ...............................................................................42
7.
.........................................................................................................................43
7.1. .........................................................................................43
7.2. ...............................................................................43
8.
....................................................................................................................45
8.1. OpenDialog SaveDialog..........................................................45
8.2. OpenDialog SaveDialog ......................................45
8.3. ......................................................................46
8.4. ...............................................................................51
9.
........................................................................................................53
9.1. ............................................................................53
9.2. Chart....................................53
9.3. ...............................................................................54
10. .....56
10.1. ..........................................................................................56
10.2. ...............................................................................56
10.3. .............................................................................59
11.
...............................................................................................................61
11.1. .......................................................................................61
11.2. .............................................................................61
12.
........................................................................................................................62
12.1. .......................................................................................62
12.2. .............................................................................62
13.
...................................................................................................................64
13.1. .......................................................................................64
13.2. .............................................................................64
14.
...................................................................................................................66
3
14.1. ....................................................................................... 66
14.2. ............................................................................ 66
15. ................... 68
15.1. ......................... 68
15.2. .................................................................... 73
15.3. ............................................................................ 76
16. .
........................................................................ 77
16.1.
..................................................................................... 77
16.2. .................................................................... 80
16.3. ............................................................................ 83
17. .................... 84
17.1. ........................... 84
17.2. .................................................................... 84
17.3. ............................................................................ 86
18.
............................................................................. 88
18.1. ........................................... 88
18.2. .................................................................... 88
18.3. ............................................................................ 91
19.
.............................................................. 92
19.1.
............................................................................................................... 92
19.2. .................................................................... 98
19.3. .......................................................................... 100
1.
............................................................................................... 102
2. .................................................... 104
3. ASCII...................................................... 105
......................................................................................................... 107
1. DELPHI.
:
Delphi.
.
1.1. Delphi
Delphi
, ,
, . . 1.1
Borland Delphi 7.0.
.
(),
, , , ,
.
( c F11)
. Properties ()
, Events ()
(,
).
.
.
,
. Delphi
Object Pascal.
Windows-.
,
( uses) ( type) (. 1.1).
Delphi ,
(,
OnClick, OnCreate).
, Events
(procedure), begin end
Object Pascal .
F12.
1.2. Delphi
Delphi
(*.pas), (*.dfm)
, (*.dpr),
, (*.res), , , ,
, (*.dof),
(*.dcu), (*.pas)
, (*.exe).
,
.
Delphi .
(Unit)
.
, Object Pascal.
:
unit Unit1;
interface
//
implementation
//
begin
//
end.
, , ,
,
(Uses).
, , , ,
, ,
.
. Delphi
dcu,
pas dfm.
dcu exe.
, ~df, ~dp, ~pa,
, .
1.3.
: x, y, z
| e3 y x 2 |
2
.
u = tg ( x + y ) *
arctg ( z ) + ln( x)
, . 1.2.
1.3.1.
File>New>Application.
, :
,
,
. ,
.
1.3.2.
( Name) (
Caption) Form1.
Properties
Caption , .
1.3.3. (Edit)
, ,
, Edit.
( String)
Text.
Edit x, y, z (. . 1.2).
Standard ,
. Edit,
(. 1.1) Edit1, Edit2,
Edit3. ,
. ,
Edit ( Font). Text
x, y, z.
,
x, y, z , Edit
Text .
, Edit.Text,
StrToFloat, x:=StrToFloat(Edit1.Text).
StrToInt.
,
,
Windows ( ).
1 7.
1.3.4. (Label)
. 1.2 .
Label.
(
Standard).
Caption ().
1.3.5. (Memo)
Memo (
Standard).
,
Properties
ScrollBars SSBoth. ,
Memo, Memo.Lines.
8
Memo.Lines.Add().
Memo.Clear. Memo ,
,
String:
FloatToStr() FloatToStrF(), IntToStr(). ,
n:=100 Memo1.Lines.Add( n=+IntToStr(n)),
x:=-256,38666
Memo1.Lines.Add( x=+FloatToStrF(x,fffixed,8,2)).
fffixed , 8
, 2 (
).
1.3.6. Close
, BitBtn
Additional
Button.
,
Clyph. , Kind, 11
. bkClose
.
1.3.7. (FormCreate)
, ,
( OnCreate).
(TForm1.FormCreate).
Memo1.
. ,
: Procedure TForm1.FormCreate(Sender:TObject).
begin end (. ,
).
1.3.8. (ButtonClick)
( Button),
Standart
.
Caption.
.
Procedure TForm1.ButtonClick(Sender:TObject);
Begin
9
End;
(. 1).
! ButtonClick FormCreate
Delphi (
).
, begin nd
Delphi.
.
,
Additional BitBtn.
Kind bkClose.
1.3.9.
, Run >Run
F9,
.
, ,
exe.
(. 1.2).
. 1.2.
.
x, y, z.
. Memo1 .
10
x, y, z
Memo1 .
Close
, Delphi Run > Program Reset.
.
1.1 . , ,
,
, Delphi .
unit Unit1;
1.1
interface
uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,
Controls,Forms,Dialogs,Buttons,StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Memo1: TMemo;
Button1: TButton;
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Clear;
//
end;
11
2cos x
z2
6
1. t =
1 +
.
0.5 + sin 2 y 3 z 2 / 5
8 + x y +1
x y
( tg
z +1 .
x2 + y 2 + 2
x=-4.5, y=0.7510-4, z=0.845102 u=-55.6848.
1 + sin 2 ( x + y ) y
1
3. v =
x + cos 2 arctg .
z
2y
x
2 2
1+ x y
x=3.7410-2, y=-0.825, z=0.16102, v=1.0553.
z 2 z3 z 4
1+ 2sin 2 y )
(
4. w = cos x cos y
1 + z + + + .
2 3 4
( )
12
6. = 10
x + x y +2
) ( arcsin
z x y .
y
xx
cos y
=39.374.
z
( y x)
y
.
+ ( y x)
2
x
1 + ( y x)
e x1/ sin z .
sin 2 z
x y 1 +
x + y
3 x
3
11. b = y + cos ( y )
.
x
x y
+
e
2
x=6.251, y=0.827, z=25.001 b=0.7121.
y arctgz
x
y
6
(y )
12. = 2 + 3x
.
1
x+ 2
y +1
x=3.251, y=0.325, z=0.46610-4 c=4.2514.
( )
13. f =
y + 3 x 1
x y sin 2 z + tgz
2. DELPHI.
:
(CheckBox, RadioGroup).
.
2.1.
, ,
. ., Windows
. Delphi
.
Events .
. ,
Events, ,
() . Delphi
. ,
.
. 2.1.
2.1
OnActivate
OnCreate
OnKeyPress
OnKeyUp
OnClick
OnDblClick
(, ).
,
. Key
Char ASCII-
( Enter #13, Esc #27
..)
OnKeyDown
14
, 2.1,
.
. 2.1.
2.4.1. Co
, , ,
Edit.
2.4.2. heckBox
Standard
.
( Caption) .
CheckBox1 TCheckBox. ,
,
CheckBox1.Checked
true false.
16
2.4.3. RadioGroup
Standard
.
RadioGroup1. (
Caption) .
, Columns
( ).
Items
. :
sin(x), cos(x), exp(x) .
. ,
RadioGroup1 TRadioGroup.
RadioGroup1.ItemIndex
, .
. 2.1. 2.1.
Unit Unit1;
2.1
interface
uses Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,Dialogs, Buttons, StdCtrls,
ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Memo1: TMemo;
RadioGroup1: TRadioGroup;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
17
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
// 1- RadioGroup1
radiogroup1.itemindex:=0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var x,y,f,r:extended;
s:string;
begin
x:=strtofloat(edit1.Text);
y:=strtofloat(edit2.Text);
case radiogroup1.itemindex of
0: begin f:=sin(x); s:='sin(x)';
1: begin f:=cos(x); s:='cos(x)';
2: begin f:=exp(x); s:='exp(x)';
end;
end;
end;
end;
if(x>1)and(x<2)then r:=sqr(f+y)
else if(x>4)and(x<5)then r:=f*f+ln(abs(3*y))
else r:=f+cos(y);
if CheckBox1.Checked then
memo1.Lines.Add('x='+edit1.Text+' y= '+edit2.Text+
' f(x)='+s+
' ='+inttostr(round(r)))
else
memo1.Lines.Add('x='+edit1.Text+' y= '+edit2.Text+
' f(x)='+s+
' ='+floattostrf(r,fffixed,8,3));
end;
end.
2.5.
110
, 1115
18
.
f(x) : sh(x), x2 ex.
r = ln( y + 2) + f ( x), x / y > 0
r = ( f ( x) + y ) 2 , x y > 10
r = f ( x) cos( y ), x y < 1
1.
r = f ( x) + y,
f ( x)
r = e + sh( y ), 5 < x < 9
r = ch( y ) + f ( x) 4 , x > 10
r = f ( x) tg ( y ),
r = f ( x)3 + ctg ( y ), x y > 12
4.
5.
6.
7.
r = cos( x f ( x)3 ),
r = ( f ( x) + y ) 2 , 1 < x y < 4
r = f ( x) tg ( y ), 8 < x y < 10
3.
9.
11.
12.
13.
r = f ( x) + y,
r = ctg ( y ) + f ( x),
r = ln y + tg ( f ( x)),
r = f ( x) y 3 ,
r=
x/y > 0
x/ y < 0
r = cos( x + f ( x)3 ),
r = e f ( x ) + cos( y ), 2 < x < 4
r = sh( y ) + f ( x) 4 , x > 10
r = f ( x) tg ( y ),
3
r = f ( x) + sin( y ), x y < 0
r = ch( f ( x)3 ) + y 2 , x y > 11
10.
r = tg ( x + f ( x)3 ),
+ 5.
, y z , sin( y ) + 5 z )
max f ( x ), cos( y ),
r=
8.
min f ( x ) + 1, y 3 1, sin( z )
3
r = ln y + f ( x) , 3 < x y < 8
r = cos( f ( x)) y, x y > 12
r = sh( f ( x) + cos( y )),
r = f ( x)3 + sin( y ), x y < 5
max f ( x ), y + 3, z 2 1
(
min ( f ( x ) + y
r=
2.
z + 12
2
max f ( x) + y, y2 + z, xyz
14.
r=
15.
min f ( x) + y, cos( y) + z, x + y+ z
y2 + z2 .
19
3.
DELPHI.
:
Delphi.
.
3.1. Delphi
. ( )
(
). Delphi
, .
,
, . ,
, .
.
Help F1.
, ,
.
, . ,
,
. ( )
. ,
.
, . .
,
. ,
Delphi.
.
F4 ( )
( ) F9.
.
(
), Ctrl+F7 ( )
Ctrl+F5 ( )
. F7 ( ),
,
. ,
20
F4
. <Run> <Run>
F9.
3.2. repeat, while, for
()
.
.
Object Pascal
.
repeat
< ( )>
until < >;
,
repeat until ( ), , <
>, .
While < > do
begin
< ( >
end;
, begin end (
), < >. ,
< > ,
, repeat,
.
for i:=m to n do
begin
< ( >
end;
i m n . ,
m>n, < > .
Break,
.
Continue.
3.3.
: ,
xk
y ( x ) = e x s ( x) = a k = (1) k
k!
k =0
k =0
, a b c h. s(x)
. ,
.
(
,
).
1
k: k = 0; a0 = 1 ;
1
x
xx
xxx
k = 1; a1 = 1 ; k = 2; a2 = 1
; k = 3; a3 = 1
. . ,
1 2 3
1
1 2
x
1 .
k
, :
x
ak = ak 1 ; .
k
. ,
. . 3.1.
3.1..
22
. 3.1.
Unit Unit3;
3.1
interface
uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,
Controls,Forms,Dialogs,Buttons,StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label2: TLabel;
Edit4: TEdit;
Label3: TLabel;
Button1: TButton;
Memo1: TMemo;
BitBtn1: TBitBtn;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
23
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a,b,h,x,w,s,y,eps:extended;
k:integer;
begin
a:= StrToFloat(Edit1.Text);
b:= StrToFloat(Edit2.Text);
h:= StrToFloat(Edit3.Text);
eps:=StrToFloat(Edit4.Text);
x:=a; Memo1.Clear;
repeat
s:=1; w:=1; k:=0;
repeat
inc(k);
w:=-w*x/k;
s:=s+w;
until abs(w)<eps;
y:=exp(-x);
Memo1.Lines.Add(FloatToStrF(x,fffixed,5,2)+
' '+FloatToStrF (s,fffixed,9,6)+
' '+FloatToStrF (y,fffixed,9,6)+
' '+IntToStr(k));
x:=x+h;
until x>b+1e-6;
end;
end.
3.4.
y(x)
s(x) x a b h
. s(x) y(x)
x s(x) y(x).
,
F4. , F7,
, .
24
. 3.1
xn
s(x)
xk
x 2 n+1
(1) (2n + 1)!
n =0
1.
0.1
0.001
sin x
0.0001
e x + e x
2
2.
3.
0.1
0.1
1
1
x 2n
(2n)!
n =0
n =0
4.
0.1
cos n
n!
4 xn
x2n
(1) (2n)!
n =0
n
5.
0.1
0.7
1
x 2 n+1
(2n + 1)!
n =0
0.1
0.0001
cos x
0.001
cos( x sin )
4
(1 + 2 x 2 )e x
0.0001
e x e x
2
0.001
9x
0.0001
e2 x
0.001
x 2 x 2x
+ + 1 e
4 2
0.0001
arctgx
0.001
x2
x
1 cos x sin x
2
2
0.0001
2(cos 2 x 1)
0.0001
sin( x)
x
0.0001
1 x +1
sh x ch x
4 x
6.
x cos
0.001
2n + 1
n! x 2 n
n =0
y(x)
7.
0.2
(ln 9) n n
n! x
n =0
8.
0.1
0.7
(2 x) n
n!
n =0
9.
0.3
1
0.5
x 2 n+1
(1) 2n + 1
n =0
10 0.1
11 0.2
2n 2 + 1 2 n
(1) (2n)! x
n =0
n
12 0.1
1
(1)n
n =1
13 -2
n2 + 1 x
n! 2
n =0
-0.1
(2 x) 2 n
(2n)!
x 2n
(1) (2n + 1)!
n =0
n
14 0.2
0.8
n2
(2n + 1)! xn
n =1
25
15 0.1
0.8
(1)
n =1
n +1
x2n
2n(2n 1)
0.001
xarctgx ln 1 + x 2
26
4. .
: StringGrid.
.
4.1.
,
. ( TApplication.HandleException),
,
.
Object Pascal try,
.
try finally:
try
<,
>
finally
<, ,
>
end;
finally.
. finally
, ,
. ,
,
.
tryexcept:
try
<,
>
except
<,
>
end;
27
except, except .
.
except ,
.
except , case:
on < 1> do < 1>;
on < 2> do < 2>;
else <,
>;
, do
.
4.1.
. 4.1
,
EAbort
Abort
:
EArrayError
,
(
mxarrays)
EConvertError
EDivByZero
ERangeError
(
{$R+})
(
EIntOverflow
{$Q+})
EInvalidArgument
EZeroDivide
EOutOfMemory
EInvalidOp
EOverFlow
EAssertionFailed
Assert (
{ $+ })
28
! ,
, Stop on Delphi Exceptions
Tools > Debbuger Options , Language Exceptions.
. Abort (
), Assert (Exp: Boolean [; const Msg: string])
(
Exp , ,
Msg ( )),
Raise,
(< >) ,
:
Raise < >.Create(< >);
4.2. ShowMessage MessageDlg
ShowMessage
MessageDlg, ShowMessage(Msg: string)
OK .
. MessageDlg(const Msg:
WideString; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint):
Word
(mrYes, mrOK, mrHelp ..),
, MessageDlg('Error', mtError, [mbOK, mbNo], 0);. Msg
, DlgType (.
4.2).
. 4.2
mtWarning
mtError
mtInformation
mtConfirmation
mtCustom
-
,
Buttons ,
(. 4.3). .
. 4.3
mbYes
mbNo
mbOK
mbCancel
mbRetry
mbIgnore
mbAbort
mbHelp
mbAll
mbNoToAll
mbYesToAll
29
HelpCtx (
0).
, .
, mr , : mrYes, mrOK, mr
Help.
4.3.
,
. ,
,
, : a[3], b[k], c[k, 2*k].
LongInt.
(Type)
(Var) :
Array [ ] of < >;
:
Const Nmax=20; //
Type vek=array[1..Nmax] of extended; //
Var a: vek;
// a extended
s : array[1..10] of integer; // s integer
y : array[1..5, 1..10] of char; // y
,
, :
f:=2*a[3]+a[s[4]+1]*3; a[n]:=1+sqrt(abs(a[n-2]));
4.4. StringGrid
. StringGrid
,
( Edit).
Cells[ACol: Integer;
ARow: Integer]: String, ACol, ARow -
Cells. ColCount RowCount
, FixedCols FixedRows
, ,
.
.
. StringGrid
). StringGrid
Additional (
,
Options
30
( +, Options) goEditing
True.
4.5.
: n-
A - b. y
n
yi = Aij b j , i=1, n n
j =1
Edit, b
StringGrid.
StringGrid. . 4.1.
4.1.
. 4.1.
unit Unit1;
4.1
interface
uses
Dialogs, Grids,
31
Buttons, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
StringGrid1: TStringGrid;
BitBtn1: TBitBtn;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const max=10; //
//
vek=array[1..max] of extended;
var
Form1: TForm1;
a:mat;
//
b,y:vek; //
n,i,j:integer;
implementation
32
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
n:=strtoint(edit1.Text); //
StringGrid1.RowCount:=n+1;
StringGrid1.ColCount:=n+1;
StringGrid2.RowCount:=n+1;
StringGrid3.RowCount:=n+1;
StringGrid1.cells[0,0]:= '
a';
StringGrid2.cells[0,0]:= '
b';
StringGrid3.cells[0,0]:= '';
for i:=1 to n do
StringGrid1.cells[0,i]:= '
i='+inttostr(i);
for j:=1 to n do
StringGrid1.cells[j,0]:= '
j='+inttostr(j);
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
//
if edit1.text='' then
exit;
n:=strtoint(edit1.Text);
StringGrid1.RowCount:=n+1;
StringGrid1.ColCount:=n+1;
StringGrid2.RowCount:=n+1;
StringGrid3.RowCount:=n+1;
for i:=1 to n do
StringGrid1.cells[0,i]:= '
i='+inttostr(i);
for j:=1 to n do
StringGrid1.cells[j,0]:= '
j='+inttostr(j);
end;
33
Exit; end;
34
on EOverFlow do
begin
MessageDlg('
', mtError,[mbCancel],0);
Exit; end;
else
begin
MessageDlg('
! ',mtError,[mbCancel],0);
Exit; end;
end;
// StringGrid3
for i:=1 to n do
StringGrid3.Cells[0,i]:=FloatToStrf(y[i],fffixed,6,2);
end;
end.
4.6.
StringGrid, 0- 0-
.
.
1. , n m .
,
.
2. , n m .
, .
3. , n m .
,
, .
4. , n m .
, ,
.
5. , n m .
, ,
, , , .
6. , n m .
.
7. , n m .
.
35
8. , n m .
.
9. , n-
.
10. , n m .
.
11. n- ,
, ,
.
12. n m ,
,
.
13. n- (n-1)-
,
.
14. n- ,
, , .
15. , n m .
.
36
5.
:
.
5.1.
Object Pascal, , ,
,
. ,
, , ,
.
.
c
.
5.2.
.
.
1. . 3-
.
2. . :
, ,
.
3. . ,
.
4. .
(. . ).
5. . k
.
6. .. k
.
7. . :
,
, .
8. X Y
Z ,
Z .
9. .
1- .
37
10. .
, .
11. . 1-
2- .
12. .
, .
13. .
.
14. . .
15. . .
38
6.
: Delphi
. ,
Unit .
6.1.
,
, , .
. 1.2 :
, , ,
( ).
Unit
,
. Uses
.
interface
implementation
, .
implementation
, .
,
, , ,
.
initialization
,
( ).
finalization
( ).
6.2.
Delphi ,
. File
New > Unit. Unit
Unit2, .
, , Unit biblio.
biblio.pas.
, .
.
39
6.3.
,
Project Add to Project , .
Uses biblio.
, .
6.4.
: ,
.
xk
.
y ( x ) = e x s ( x) = (1) k
k
!
k =0
. 6.1.
( 6.1) ( 6.2)
.
unit biblio;
6.1
interface
function y(x:extended):extended;
procedure sum(x,eps:extended; var s:extended;
var k:word);
40
implementation
function y;
begin
result:=exp(-x);
end;
procedure sum;
var w:extended;
begin
s:=1; w:=1; k:=0;
repeat
inc(k);
w:=-w*x/k;
s:=s+w;
until abs(w)<eps;
end;
end.
unit Unit1;
6.2
interface
uses
Windows,Messages,SysUtils,Variants, Classes, Graphics,
Controls,Forms, Dialogs, Buttons, StdCtrls, biblio;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label2: TLabel;
Edit4: TEdit;
Label3: TLabel;
Button1: TButton;
Memo1: TMemo;
BitBtn1: TBitBtn;
Label4: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
41
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
end;
procedure TForm1.Button1Click(Sender: TObject);
var a,b,h,x,eps,s:extended;
it:word;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
h:=strtofloat(edit3.Text);
eps:=strtofloat(edit4.Text);
x:=a;
repeat
sum(x,eps,s,it);
memo1.Lines.Add(floattostrf(x,fffixed,5,2)+
'
'+floattostrf(s,fffixed,9,6)+
'
'+floattostrf(y(x),fffixed,9,6)+
'
'+inttostr(it));
x:=x+h;
until x>b+0.0000000001;
end;
end.
6.5.
.
,
. ,
.
.
42
7.
:
. .
7.1.
,
. R -
R = an an1 K a1a0 , a1 K a k = an p n + an1 p n1 + K + a1 p1 + a0 p 0 + a1 p 1 + K + a k p k ,
ai , p . p.
p
. p10 09, p>10
A, B, C, D, E, F,
10, 11, 12, 13, 14, 15.
R = ( D3, E )15 = D 151 + 3 150 + E 151 = 13 151 + 3 150 + 14 151 = (198,93)10
R = (124,5)8 = 1 82 + 2 81 + 4 80 + 5 81 = (84,625)10
: , .
, .
.
,
. ,
,
a0 , a1 ,K , an , .
, . ,
, .
.
a1 , a2 ,K , a k ,
.
.
7.2.
.
TComboBox. .
43
1. , .
.
2. ,
. ,
.
3. ,
. ,
.
4. ,
. ,
.
5. , ,
.
.
6. , .
, , .
7. , ,
(, , , .).
,
, .
8. , ,
(, , , .).
.
9. , ,
(, , , .).
.
10. , ,
. .
11. ,
. ,
12. ,
. ,
k- ( k- ,
).
13. , ,
(, , , .).
.
14. , .
,
.
15. , .
.
44
8.
:
OpenDialog SaveDialog. .
.
8.1. OpenDialog SaveDialog
OpenDialog SaveDialog Dialogs
. , . .
.
.
.
,
.
a FileName. ,
, Filter,
, , ,
DefaultExt. ,
Title.
8.2. OpenDialog SaveDialog
OpenDialog SaveDialog ,
Dialogs
, Filter
. Filter Editor,
, ,
. OpenDialod
. 8.1. *.dat ,
dat, *.* (
). , , ,
dat, DefaultExt SaveDialog1
dat, ( txt).
45
. 8.1.
8.3.
: ,
(
, ), ,
,
.
. 8.2. .
46
. 8.3. .
8.1.
unit Unit1;
8.1
interface
uses Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
47
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
BitBtn1: TBitBtn;
Memo1: TMemo;
Memo2: TMemo;
Memo3: TMemo;
Memo4: TMemo;
Label5: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type stud=record
fam:string[20];
oc:array[1..3] of byte;
end;
var
Form1: TForm1;
f:file of stud;
ft:textfile;
w:stud;
zak:boolean;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
button1.Enabled:=false;
zak:=false;
end;
48
end;
closeFile(f);
label5.Caption:='
end;
';
end;
end;
closeFile(f);
label5.Caption:=' ';
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if zak then closeFile(f);
end;
end.
8.4.
. ,
, ,
.
.
1. , .
: ,
. ,
.
2. , ,
, .
, .
3. ,
, , .
,
,
.
.
4. .
, .
,
.
5. :
. 144
.
, 12% .
51
6. :
, .
.
7. , , : , ,
. ,
.
8.
. : ,
, .
.
9. : ,
.
.
10. ,
, : , , .
, .
4.5, .
11. .
: , , .
.
12.
:
, , .
.
.
13. ,
, : , .
,
.
14.
. :
(, . .), ,
(, ).
.
15.
, , .
.
52
9.
:
Tanvas
hart.
9.1.
Delphi
(, , PaintBox),
Image ( Additional). Image
ClipBoard.Assign(Image.Picture) ( Clipbrd).
Tanvas, ,
. (x, y),
x , , y
, .
(0, 0), (Image.Width -1, Image.Height - 1).
9.2. Chart
. Delphi
,
Chart.
()
y=f(x).
Chart.SeriesList[k] (k (0,1,2,...)) hart
AddXY. Chart
, Chart.SeriesList[k]:
, ,
,
. ,
EditingChart hart ,
, ,
.
Chart. , , Chart.BottomAxis
.
Chart.CopyToClipboardMetafile(True).
Chart .
53
EditingChat1 (. 9.1).
Series1 Add Series.
TeeChart Gallery Line (
).
, 3D. OK
Series1.
Title. Legend (
). Titles.
Axis. Series (,
) . ,
EditingChart.
TCanvas
. Image,
2/3 . .
54
1. , b, . ,
.
2. , b, , d. ,
.
3. R1 R2
(x1 , y1), (x2 , y2 ) .
4. R
(x0 , y0 ) , (x1 , y1)
(x2 , y2 ) (, , ).
5. ,
R (x0 , y0 )
6. R1 R2
(x1 , y1) (x2 , y2 ) .
7. ,
(1 , 1) ++=0.
8. 1 (x1 , y1), 2 (x2 , y2 ) +By+=0.
0 (x0 , y0 )
.
9. (x1 , y1), (x2 , y2 ) , (x3 , y3 )
,
. .
10. (x1 , y1), (x2 , y2 ), (x3 , y3 ), (x4 , y4 ).
, .
11. (x1 , y1), (x2 , y2 ), (x3 , y3 ), (x4 , y4 ).
, : ) ; ) ; ) .
12. (x1 , y1) (x2 , y2 ) .
.
13. (x1 , y1) (x2 , y2 ) ,
, (x3 , y3 ). ,
.
14. (x1 , y1), (x2 , y2 ), (x3 , y3 ) .
.
15. (x1 , y1), (x2 , y2 ) ,(x3 , y3 ) .
.
55
10.
:
.
10.1.
,
.
10.2.
.
.
. 10.1.
unit Unit1;
10.1
interface
uses Windows,Messages,SysUtils,Variants,Classes,Graphics,
Controls, Forms,Dialogs, StdCtrls, Grids, Buttons;
type
56
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Edit1: TEdit;
BitBtn1: TBitBtn;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
Label2: TLabel;
Button5: TButton;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type vek=array[1..50] of byte;
var Form1: TForm1;
a:vek;
n,k:integer;
implementation
{$R *.dfm}
function maxRn( x:vek; n:integer ):byte;
begin
if n=1 then result:=x[1]
else
if maxRn(x,n-1)>x[n] then result:=maxRn(x,n-1)
else result:=x[n];
end;
function max( x:vek; n:integer ):byte;
begin
result:=x[1];
for k:=1 to n do
if x[k]>result then result:=x[k];
57
end;
function sqrtR( x:extended; n:integer ):extended;
begin
if n=0 then result:=x
else result:=0.5*(sqrtR(x,n-1)+x/sqrtR(x,n-1));
end;
function sqrtA( x:extended; n:integer
begin
result:=x;
for k:=1 to n do
result:=0.5*(result+x/result);
end;
):extended;
label5.Caption:='sqrt(x)='+
floattostrf(sqrtR(strtofloat(edit2.Text),n),fffixed,9,5)
+' ';
label6.Caption:='sqrt(x)= '+
floattostrf(sqrtA(strtofloat(edit2.Text),n),fffixed,9,5);
end;
end.
10.3.
.
.
1. n!=1*2*3**(n-1)*n, 0!=1.
2. ai, i=1...n
c , : c an / 2 ,
c [ a1...an / 2 ] c [ an / 2 +1...an ] . c
, .
3. m n.
( ): m n, (n, m)=n,
(n, m)= (m mod n, n).
4. Fb(n).
: Fb(0)=1; Fb(1)=1; Fb(n)=Fb(n-1)+Fb(n-2).
5. .
6. n- ,
n
7. x = a ,
1
xn = ( xn 1 + a xn 1 ) ,
2
x0=0.5(1+a).
8. a1...an,
max (a1...an)=max (max (a1...an-1), an).
9.
a1...an,
( ) max (a1...an)=max (max (a1...an/2), max
(an/2+1, an)).
10. y ( n ) = n + n 1 + n 2 + ... + 2 + 1 .
59
11. y ( n ) =
1
n+
1
(n 1) +
1
1
.. ..
1
.... +
1
1+ .
2
(n )
(n 2) +
12. n2
2 2 4 4 6 6
y = ....
1 3 3 5 5 7
13. y = x n : y = ( x n / 2 )2 , n
y = x x n 1 , n .
n!
, m n.
14. Cnm =
m!(n m)!
15. A(m, n),
m n :
A(o, n)=n+1;
A(m, o)=A(m-1, 1); (m>o);
A(m, n)=A(m-1, A(m, n-1)); (m>o; n>o).
60
11.
:
, .
11.1.
.
11.2.
. ,
8.
, .
61
12.
:
.
12.1.
.
12.2.
. ,
.
1. 50 +50
.
, .
, .
2.
.
3. 10 10
.
4.
.
5. , , ,
.
6.
.
7. ,
, ,
.
8. ,
, ,
.
9. ,
.
10. ,
.
11.
.
62
12. .
, .
13. 1 10
.
14.
.
15.
.
63
13.
:
, .
13.1.
.
13.2.
.
,
.
1. 50 +50
.
, .
, .
2.
.
3. 10 10
.
4.
.
5. , , ,
.
6.
.
7. ,
, ,
.
8. ,
, ,
.
9. ,
.
10. ,
.
11.
.
64
12. .
, .
13. 1 10
.
14.
.
15.
.
65
14.
:
, .
14.1.
.
14.2.
.
,
,
.
1. 50 +50
.
, .
, .
2.
.
3. 10 10
.
4.
.
5. , , ,
.
6.
.
7. ,
, ,
.
8. ,
, ,
.
9. ,
.
10. ,
.
66
11.
.
12. .
, .
13. 1 10
.
14.
.
15.
.
67
15.
:
,
,
Delphi.
15.1.
.
.
68
. 15.1.
69
s = |w|
kk
. 15.2.
70
. 15.3.
71
k=1
m=2
i=1,n
A,n,eps
i=1,n-1
j=1,n
j=i+1,n
pij=bij aij=0
|aij|>|akm|
k=1,n
i=1,n
j=1,n
i=j
k=i m=j
pij=0
aij=aij+tki*ckj
pij=1
max=|a12|
akk=amm
i=1,n-1
f=*arctg(2akm
/(akk-amm))
f=/4
j=i+1,n
i=1,n
|aij|>max
j=1,n
max=|aij|
i=j
tij=1
tij=0
tkm=-sin(f) tmk=sin(f)
tkk=cos(f) tmm=cos(f)
max<eps
A,P
i=1,n
j=1,n
bij=0
cij=0
k=1,n
bij=bij+pik*tkj
cij=cij+aik*tkj
. 15.4.
72
15.2.
.
Gauss(a,b,n,x),
.
. 15.1.
unit biblio;
15.1
interface
type mat=array[1..30,1..30] of extended;
vek=array[1..30] of extended;
procedure Gauss(a:mat; b:vek; n:integer; var x:vek);
implementation
procedure Gauss;
var k,m,p,i,j:integer;
r,c,s:extended;
begin
for k:=1 to n-1 do
begin
p:=k;
73
for m:=k+1 to n do
if abs(a[p,k])<abs(a[m,k]) then p:=m;
for j:=k to n do
begin
r:=a[k,j];
a[k,j]:=a[p,j];
a[p,j]:=r;
end;
r:=b[k];
b[k]:=b[p];
b[p]:=r;
for m:=k+1 to n do
begin
c:=a[m,k]/a[k,k];
b[m]:=b[m]-c*b[k];
for i:=k to n do
a[m,i]:=a[m,i]-c*a[k,i];
end;
end;
x[n]:=b[n]/a[n,n];
for k:=n-1 downto 1 do
begin
s:=0;
for i:=k+1 to n do
s:=s+a[k,i]*x[i];
x[k]:=(b[k]-s)/a[k,k];
end;
end;
end.
unit Unit1;
15.2
interface
uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,
Controls,Forms,Dialogs,Buttons,Grids,StdCtrls,biblio;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
74
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a:mat;
b,x:vek;
n,i,j:integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
n:=3; edit1.Text:=inttostr(n);
stringgrid1.Cells[0,0]:='
A';
stringgrid2.Cells[0,0]:='
B';
stringgrid3.Cells[0,0]:='';
stringgrid1.RowCount:=n+1;
stringgrid1.ColCount:=n+1;
stringgrid2.RowCount:=n+1;
stringgrid3.RowCount:=n+1;
for i:=1 to n do
begin
stringgrid1.Cells[i,0]:=' i='+inttostr(i);
stringgrid1.Cells[0,i]:=' j='+inttostr(i);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
n:=strtoint(edit1.Text);
stringgrid1.RowCount:=n+1;
stringgrid1.ColCount:=n+1;
stringgrid2.RowCount:=n+1;
stringgrid3.RowCount:=n+1;
for i:=1 to n do
begin
75
stringgrid1.Cells[i,0]:='
stringgrid1.Cells[0,i]:='
end;
i='+inttostr(i);
j='+inttostr(i);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
for i:=1 to n do
for j:=1 to n do
a[i,j]:=strtofloat(stringgrid1.Cells[j,i]);
for i:=1 to n do
b[i]:=strtofloat(stringgrid2.Cells[0,i]);
Gauss(a,b,n,x);
for i:=1 to n do
stringgrid3.Cells[0,i]:=floattostrf(x[i],fffixed,9,5);
end;
end.
15.3.
n- ,
n- .
,
1. .
2. .
3. .
4. .
5. .
6. .
7.
.
8. .
9. .
76
16. .
:
Delphi.
16.1.
.
.
77
16.1.
78
16.2.
79
16.2.
.
lag(xt,x,y,n) Gauss2(a,b,m,f), .
. 16.1.
unit biblio;
16.1
interface
type vek=array[1..30] of extended;
fun=function(x:extended):extended;
function lag(xt:extended; x,y:vek; n:integer):extended;
function gauss2(a,b:extended; n:integer;
f:fun):extended;
implementation
function lag;
var i,k:integer;
s,p:extended;
begin
s:=0;
for k:=1 to n do
80
begin
p:=y[k];
for i:=1 to n do
if i<>k then p:=p*(xt-x[i])/(x[k]-x[i]);
s:=s+p;
end;
result:=s;
end;
function gauss2;
const c=0.5773502692;
var x,h,s:extended;
k:integer;
begin
h:=(b-a)/n;
x:=a+h/2; s:=0;
for k:=1 to n do
begin
s:=s+f(x-h/2*c)+f(x+h/2*c);
x:=x+h;
end;
result:=h*s/2;
end;
end.
unit Unit1;
16.2
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, TeEngine,
Series, Buttons, StdCtrls, ExtCtrls, TeeProcs,
Chart, biblio;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label2: TLabel;
Chart1: TChart;
Button1: TButton;
Button2: TButton;
BitBtn1: TBitBtn;
81
Label3: TLabel;
Series1: TLineSeries;
Series2: TLineSeries;
Edit4: TEdit;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function f(x:extended):extended;
begin
f:=4*x-20*cos(3*x);
end;
procedure TForm1.Button1Click(Sender: TObject);
var a,b,h,xt:extended; //
n,k,m:integer;
x,y:vek;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
n:=strtoint(edit3.Text);
m:=strtoint(edit4.Text);
h:=(b-a)/(n-1);
for k:=1 to n do
begin
x[k]:=a+(k-1)*h;
y[k]:=f(x[k]);
end;
series1.Clear; series2.Clear;
for k:=0 to m do
begin
xt:=a+k*(b-a)/m;
series1.AddXY(xt,f(xt),'',clred);
82
series2.AddXY(xt,lag(xt,x,y,n),'',clblue);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var a,b:extended; //
m:integer;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
m:=strtoint(edit4.Text);
label3.Caption:='= '+
floattostrf(gauss2(a,b,m,f),fffixed,9,6);
end;
end.
16.3.
f(x)
.
f(x)
[a, b]. n,
m , .
,
. ,
.
1.
2.
3.
4.
5.
6.
:
1.
2.
3.
4.
5.
6.
83
17.
:
Delphi.
17.1.
.
17.2.
.
f(x), fp(x) nyton(x,eps,f,fp) (
, ).
. 17.1.
84
unit Unit1;
17.1
interface
uses Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, TeEngine,
Series, Buttons, StdCtrls, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label2: TLabel;
Chart1: TChart;
Button1: TButton;
BitBtn1: TBitBtn;
Series1: TLineSeries;
Memo1: TMemo;
Edit4: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit5: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
type fun=function(x:extended):extended;
function f(x:extended):extended;
begin //
f:=x*x-4;
end;
function fp(x:extended):extended;
85
begin //
fp:=2*x;
end;
function nyton(x,eps:extended; f,fp:fun):extended;
var w:extended;
begin
//
repeat
w:=x;
x:=x-f(x)/fp(x);
until abs(w-x)<eps;
result:=x;
end;
procedure TForm1.Button1Click(Sender: TObject);
var a,b,h,x,eps:extended; //
n:integer;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
h:=strtofloat(edit3.Text);
eps:=strtofloat(edit4.Text);
series1.Clear;
x:=a;
repeat
series1.AddXY(x,f(x),'',clred);
x:=x+strtofloat(edit5.Text);
until x>b+0.0000000001;
x:=a;
n:=0;
repeat
if f(x)*f(x+h)<0 then //
begin inc(n);
memo1.Lines.Add(inttostr(n)+'- = '+
floattostrf(nyton(x+h/2,eps,f,fp),fffixed,9,6));
end;
x:=x+h;
until x>b+0.0000000001;
end;
end.
17.3.
f(x)=0
[a, b] .
.
86
1.
2.
3.
4.
5.
6.
87
18.
:
Delphi.
18.1.
.
18.2.
.
gold(a,b,eps,f).
. 18.1.
88
unit Unit1;
18.1
interface
uses Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, TeEngine,Series,
Buttons, StdCtrls, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label2: TLabel;
Chart1: TChart;
Button1: TButton;
BitBtn1: TBitBtn;
Series1: TLineSeries;
Memo1: TMemo;
Edit4: TEdit;
Label3: TLabel;
Label4: TLabel;
Edit5: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
type fun=function(x:extended):extended;
function f(x:extended):extended;
begin //
f:=sqr(x-3);
end;
function gold(a,b,eps:extended; f:fun):extended;
89
const w=0.381966011;
var x1,x2,y1,y2:extended;
begin
//
x1:=a+w*(b-a);
y1:=f(x1);
x2:=b-w*(b-a);
y2:=f(x2);
repeat
if y1>y2 then
begin
a:=x1; x1:=x2; y1:=y2;
x2:=b-w*(b-a); y2:=f(x2);
end
else
begin
b:=x2; x2:=x1; y2:=y1;
x1:=a+w*(b-a); y1:=f(x1);
end;
until abs(b-a)<eps;
result:=(a+b)/2;
end;
procedure TForm1.Button1Click(Sender: TObject);
var a,b,h,x,eps:extended; //
n:integer;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
h:=strtofloat(edit3.Text);
eps:=strtofloat(edit4.Text);
series1.Clear;
x:=a;
repeat
series1.AddXY(x,f(x),'',clred);
x:=x+strtofloat(edit5.Text);
until x>b+0.0000000001;
x:=a;
n:=0; memo1.Clear;
repeat
if (f(x)<f(x-h))and(f(x)<f(x+h))then
begin inc(n);
memo1.Lines.Add(inttostr(n)+'- = '+
floattostrf(gold(x-h,x+h,eps,f),fffixed,9,4));
end;
x:=x+h;
until x>b+0.0000000001;
end;
90
end.
18.3.
n
.
.
1.
.
2.
.
3. .
4.
.
5.
.
6.
.
7.
.
8.
.
9.
.
10. .
11.
.
12.
.
13.
.
14.
.
15.
.
91
19.
:
Delphi.
19.1.
.
.
92
.19.1.
93
. 19.2. 2-
94
. 19.3. - 2-
95
Fp2(x,Yp)
a,b,n,ny,
nit,Y,eps
i=1,ny
h=(b-a)/n
ypi=yi+h*fp2i
x=a
x,Y
x=x+h/2
Fm(x,Y)
Fp(x,Yp)
i=1,ny
i=1,ny
ypi=yi+h/2*fmi
ypi=yi+h/6*
(fmi+2fp1i+2fp2i+fpi)
x=x+h/2
x,Y
Fp1(x,Yp)
Fp(x,Yp)
i=1,ny
k=2,n
ypi=yi+h/2*fp1i
i=1.ny
yi=ypi+h/2*(3fpi-fmi)
96
. 19.4. 3-
97
19.2.
.
.
. 19.1.
unit Unit1;
19.1
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, TeEngine,
Series,Buttons,StdCtrls,ExtCtrls,TeeProcs,Chart;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label2: TLabel;
Chart1: TChart;
98
Button1: TButton;
BitBtn1: TBitBtn;
Series1: TLineSeries;
Edit4: TEdit;
Label4: TLabel;
Series2: TLineSeries;
Series3: TLineSeries;
Series4: TLineSeries;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var Form1: TForm1;
implementation
{$R *.dfm}
type vek=array[1..20] of extended;
procedure fpr(x:extended; var y,f:vek; ny:word);
begin // .
f[1]:=y[1]+y[2]-2*x-exp(x)+2;
f[2]:=y[1]+y[2]-2*x;
end;
procedure wrt(x:extended; var y:vek; ny:word;
chart:TChart);
begin
chart.series[0].AddXY(x,y[1],'',clred);
chart.series[1].AddXY(x,y[2],'',clblue);
//
chart.series[2].AddXY(x,2*x,'',clgreen);
chart.series[3].AddXY(x,exp(x),'',$00FF00FF);
end;
procedure aler(a,b:extended; var y,f:vek;
ny,nx:word; chart:TChart); //
var x,h:extended;
n,i:word;
begin
h:=(b-a)/nx;
x:=a;
wrt(x,y,ny,chart);
99
for n:=1 to nx do
begin
fpr(x,y,f,ny);
for i:=1 to ny do
y[i]:=y[i]+h*f[i];
x:=x+h;
wrt(x,y,ny,chart);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var a,b:extended; //
nx,ny:word;
y,f:vek;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
ny:=strtoint(edit3.Text);
nx:=strtoint(edit4.Text);
series1.Clear; series2.Clear;
y[1]:=2*a;
y[2]:=exp(a); //
aler(a,b,y,f,ny,nx,chart1);
end;
end.
19.3.
.
.
.
. 19.1.
du1
= f1 ( x, u1 , u2 ),
dx
du2
= f 2 ( x, u1, u2 ),
dx
a x b,
u1 (a ) = u10 ,
u2 (a ) = u20
: u1 = 2 x, u2 = e x .
100
1.
2. 1-
3. 2-
4. - 2-
5. - 4-
6. 2-
7. 3-
8. 3-
f1 ( x, u1 , u2 )
1 u1 / x u2 / e x + 1
2 u1 + u2 2 x e x + 2
f 2 ( x, u1 , u2 )
u1 /(2 x) + u2 1
T. 19.1
[a, b] u1(a) u2(a)
1
[1, 3]
2
e(1)
u1 + u2 2 x
[1, 2]
e(1)
u1 + 2u2 / e x 2 x
[2, 3]
e(2)
(u1 e x ) /( x u2 )
u1 /(2 x) e x / u2 + u2
2u1 + u2 4 x
[1, 4]
e(1)
2u1 + (u2 + e x ) / e x 4 x
2 x u2 / u1
[2, 4]
e(2)
u1 u2 /(e x x )
[1, 3]
e(1)
u1 / 2 x + u2 / e x
2 x / u1 + 2u2 e x 1
u1 u2 / 2 x
[2, 3]
e(2)
u1 / x + u2 e x
2 x / u1 + u22 / e x 1
[1, 4]
e(1)
u1 + 2e x / u2 2 x
u12 / x 2 + u2 4
[1, 2]
e(1)
10 4 x / u1 u2 + e x
11 2 x / u1 + u2 / e x
u1 / 2 x u2 / e x + e x
[2, 4]
e(2)
u1 e 2 x /(u2 2 x)
[3, 4]
e(3)
12 u1 u2 /(2e x ) x + 2
13 u 21 +u2 4 x 2 e x + 2
u1 + 2u2 2 x e x
[1, 3]
e(1)
u1 e x / u2 + u2 2 x
[1, 2]
e(1)
14 u12 / 2 x 2 u2 + e x
15 u1 e x /( x u2 )
u1 e x / 2 x + u2 / e x 1
2 x / u1 + u2 1
[2, 4]
e(2)
[3, 4]
e(3)
101
1.
( ).
Function StrToFloat(S: S .
String): Extended;
Function StrToInt(S:
S .
String): Integer;
Procedure Val(S: String; S
var X, Code: Integer);
X,
.
Code ,
Function FloatToStr( Value: Value
Extended): String;
Function FloatToStrF(Value: Value
Precision
Extended; Format:
Digits (. )
TFloatFormat; Precision,
Digits: Integer) : String;
Procedure Str(X [:width
[:Decimals]]; var S: String); S; Width
Decimals, ,
FloatToStrF
Format
ffExponent
. Precision
. Digits XX.
ffFixed
. Precision
. Digits -
. :
3,14
ffGeneral
,
.
ffFixed,
Precision, -
0,00001,
ffExponent: 3,1416
102
ffNumber
ffCurrency
ffFixed -
(
Windows )
. ffNumber,
(
Windows - .). Value = *1000 : 3
141,60
103
2.
Object Pascal
.
Math.
.
Log a (x)
Ln(x)
Ln(a )
LogN(a, x)
xa
eaLn(x)
Power(x,a)
Tg (x)
Sin(x)
Cos (x)
Tan(x)
Ctg (x)
Cos (x)
Sin(x)
CoTan(x)
ArcSin(x)
x
ArcTg
2
1 x
ArcSin(x)
ArcCos(x)
ArcCtg (x)
ArcSin(x)
Math
ArcCos(x)
ArcTg (x)
Sh(x)
e x ex
2
Sinh(x)
Ch(x)
e x + ex
2
Cosh(x)
Sign( x)
1, x>0;
0, x=0;
-1, x<0
Sign( x)
104
3. ASCII
ASCII
0
16 32
1 17 33
2 18 34
3
19 35
4
20 36
5
21 37
6
22 38
7
23 39
8
24 40
9
25 41
10 26 42
11 27 43
12 28 44
13 29 45
14 30 46
15 31 47
!
"
#
$
%
&
'
(
)
*
+
,
.
/
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
. ,
, 9 ,
10 , 13
.
128
129
130
131
132
133
134
135
136
137
144 160
145 161
146 162
147 163
148 164
149 165
150 166
151 167
152 168
153 169
176
177
178
179
180
181
182
183
184
185
192
193
194
195
196
197
198
199
200
201
208
209
210
211
212
213
214
215
216
217
224
225
226
227
228
229
230
231
232
233
240
241
242
243
244
245
246
247
248
249
105
138
139
140
141
142
143
154 170
155 171
156 172
157 173
158 174
159 175
186
187
188
189
190
191
202
203
204
205
206
207
218
219
220
221
222
223
234
235
236
237
238
239
250
251
252
253
254
255
, .
106
1. . . Delphi 7 / . . .
. : , 2003.
2. . . Delphi 6: . / . . . .:
.., 2001.
3. . . / .
. , -, . 2001.
4. . . , . . , . . .
Delphi. . . . 1. ., , 2004.
5. . . Delphi. . ., ,
2005.
6. , . . / . . . . : , 1978.
7. , . . / . . . : , 1975.
8. / . . [ .]. . : ,
1963.
9. , . . / . . . : , 1982.
10. / . . [ .].
. : , 1972. .1.
11. / . . [ .].
. : , 1975. .2.
12. / . [ .].
. : , 1980.
13. . / . . : , 1982.
14. , . . / . . . .
: , 1982.
15. , . . / . . , . . . :
, 1962. .1.
16. , . . / . . , . . . :
, 1970. .2.
17. , . : / . . . : ,
1989.
18. , . . / .
. , . . . : , 1972.
19. -, . /
. -, . . : , 1972.
20. , . .
/ . . . : , 1989.
107