Вы находитесь на странице: 1из 184

. .



36 04 01 - ,
39 02 02 ,
39 02 03 ,
39 02 01 ,
39 03 01 .

2011


1. ...................................................7
1.1. ......................................7
1.2. Delphi.......................................................9
1.3. Delphi............................................................11
1.4. ......................................................................12
1.5. Delphi ................................14
1.5.1. ...................................................................14
1.5.2. ...................................................14
1.5.3. (Edit).............................................14
1.5.4. (Label) ..................................................15
1.5.5. (Memo) ..............15
1.5.6. Close ........................................................15
1.5.7. .........16
(FormCreate)........................................................................................16
1.5.8.
(ButtonClick) ........................................................................................16
1.5.9. ...............................................16
2. OBJECT PASCAL ...............20
2.1. Object Pascal ..........................................................20
2.2. ....................................................................................20
2.3. Object Pascal ......................................................24
2.3.1. ..........................................................24
2.3.2. ...............................................................24
2.4. ................................24
3.
...............................................................................................27
3.1. .................................27
3.2. goto .......................28
3.3. if........................................................28
3.4. Case ....................................................................30
3.5. , Delphi
...........................................................................................30
4. .32
4.1. .................................................32
4.2. repeat .......32
4.3. while ...33
4.4. for .........33
4.5. ...........................................................................34
4.6. ...............................................35
5.
...........................................................37
5.1. ........................................................37
2

5.2. ..............................................37
5.3. .........................................................................38
5.4. .........39
5.5. .........40
5.6. ShowMessage MessageDlg ................40
5.7. ...41
6.
...................................................................................................45
6.1. ..............................................................................45
6.2. Delphi ......46
6.3. ...................................47
7.
................................................................................................49
7.1.
......................................................................................................49
7.2. ...........................................................................49
7.3. ...........................................50
7.4. ...........................................50
8. ........................................53
8.1. ..................................................................53
8.2. ..............54
8.3. ...................55
8.4. ....................................56
9.
...................................................................................................58
9.1. .........................................................................58
9.2. ...........................................................58
9.3. ........................59
10. ..63
10.1. .....................................63
10.2. ..........63
10.3. ..................64
10.4. .......................................65
11.
..........................................................................................................................66
11.1. ..............................................................................66
11.2. ................................................................66
12.
..........................................................................................................................68
12.1. ...............................................................................68
12.2. .................................................................69
12.2.1. ..........................................................69
12.2.2. ...................................................................70
12.2.3. ....................................................70
3

12.3. ...............................................71
12.4. OpenDialog SaveDialog .......................................71
12.5. .......................................72
13.
..............................................................80
13.1. ..........................................................80
13.2. Chart ................81
14.
.....................................................................................................86
14.1. ..........................................................................86
15.2. ............................................87
15. ..................................89
15.1. ........................................89
15.2. ..............................................................89
15.3. ....................................................................90
15.3.1. .....................................................................91
15.3.2. .........................................................92
15.3.3. ..........................................................................92
15.3.4. (Hoare).............................................................94
16.
...................................................................................................95
16.1. .......................................................................95
16.2. ..............95
16.3. ..................................96
16.4. .......................................................................96
17.
.......................................................................................................101
17.1. ....................................................101
17.2. ..........101
17.3. ............................................104
17.4. ...............107
17.5. .....................................110
17.6. ............................................114
17.7. ..................116
17.8. ............120
18.
..............................................................125
18.1. .............................................125
18.2. ................................................127
18.2.1. .......................................................................127
18.2.2. ....................................................................128
18.2.3. ..................................................129
18.3. ....................................130
18.3.1. ...................................................130
4

18.3.2. ......................................................................130
18.3.3. ............................................................131
18.4. ...................................................131
19.
....................................................................................................133
19.1. ..........................................................133
19.2. ..............................................................134
19.3. ..................................................................135
20. ............................................136
20.1. .....................................................136
20.2. ..............................................................................137
20.3. .....................................139
20.3.1. ..........................139
20.3.2. ..........................139
20.3.3. ........................140
20.3.4. .................................................140
20.4. ........................................140
20.4.1. ...........................................141
21. ...............143
21.1. ..............................143
21.2. ......................................144
21.2.1. ..................................................................144
21.2.2. ...............................................................145
21.2.3. ...............................................................145
21.2.4. ...................................................................145
22. ........147
22.1. ......................................147
22.2. ................................148
22.2.1. ...................................................148
22.2.2. ...................................................................148
22.2.3. .....................................................................149
22.2.4. .................................................................150
22.2.5. .....................................................................150
22.2.6. .......................................150
23.
................................................................................................152
23.1. ....152
23.2.
................................................................................................................153
23.2.1. 1- ( ) ........................154
23.2.2. 1- ................................................154
23.2.3. 2- ................................................155
23.2.4. 2- ....................................155
23.2.5. 4- ....................................155
5

23.3. ...................................................156
23.3.1. 2- ...157
23.3.2. 3- ...157
23.3.3. 3- ..................................158
23.4. () ........................................................158
23.5. .............................159
23.5.1. ..................................................................159
23.5.2. ................................................160
24. ....................................................162
24.1. , ................162
24.2. 163
24.2.1. .......................................164
24.2.2. .....................................................164
24.2.3. ................................................................165
24.2.4. .................................166
24.2.5. .........................................167
24.2.6. ..............................................168
24.3.
.......................................................................169
24.3.1. .....................................................169
24.4. ..........................................................170
24.4.1. ........................................170
24.4.2. .........................................................171
24.4.3. .......................................................171
24.5. ............................................................174
24.5.1. .............................................174
24.5.2. ......174
24.6. ............................................................175
24.6.1. .........................175
24.7. ....................................................176
24.7.1. ...........................176
24.8. ................................177
24.8.1. ................................................177
1.
................................................................179
2. ..........................................181
3. ASCII ...........................................182
..............................................................................................184

1.
1.1.
,
:
1. .
2. .
3. .
4. .
5. .
,
.
- . -
:

( )

x,y

( )

w=x+sin(y)

( )

x>2

( )

k=1,n
( )

(
)

. 1.1.

. ( ) .
( ).
( ).

1.2. Delphi

.
.
.
, ,
, ,
, . ()
( *.exe).
.
Delphi Object Pascal. ,
1970 .
, ,
, - . Borland -

Delphi
++, Visual C++, C
Builder, Visual Basic ., Delphi
. Delphi - ().
. -
. () .
.
.
( ), . ( ) . , ,
.
. , , Memo.Clear.
9

Delphi , , , . . 1.2
Borland Delphi 7.0.

. 1.2. Borland Delphi 7.0


1 ; 2 ; 3 ;
4 ; 5 - ; 6 ;
7 ; 8 - ;
.
.
. () Delphi, (),
. (), ,
, , , .
( c F11)

. Properties ()
, Events () ,
10

(, ).
.
.
,
.
, Windows-.
, ( uses)
( type) (. 1.1).
Delphi ,
(,
OnClick, OnCreate). , Events
(procedure),
begin end Object Pascal
.
F12.
1.3. Delphi
Delphi
(*.pas), (*.dfm)
, (*.dpr),
, (*.res), , , , , (*.dof),
(*.dcu), (*.pas)
, (*.exe).
,
. Delphi .
(Unit)
.
, Object Pascal.
:
unit Unit1;
interface
//
implementation
//
begin
11

//
end.
, , , , (Uses). , , ,
, , , .
.
Delphi dcu,

pas dfm.
dcu exe. ,
~df, ~dp, ~pa, ,
.
( *.dpr, *.pas, *.dfm, *.res. ).
1.4.
,

.

.
| e3 y x 2 |
2
u tg ( x y ) *
, x, y, z .
arctg ( z ) ln( x)
-. , , , . , . , .
, . 1.3.

12

x,y,z
a=tg2(x+y)
b=|e3y-x2|

arctg ( z ) ln( x)
s=a*b/c

x,y,z,s

. 1.3.
, .
a,b,c . Delphi
( Edit) ( StringGrid).
( Memo).
.
, ,
. , , , Edit1
28.64 Edit1.Text:=28,64.
Memo1. . Memo1.Lines.Add( ).
. FloatToStrF(,fffixed,6,2) x 6
13

IntToStr(m) m .
1.5. Delphi
: x, y,
z
| e3 y x 2 |
u tg 2 ( x y ) *
.
arctg ( z ) ln( x)
, . 1.4.
1.5.1.

File>New>Application.
, : , ,
. ,
.
1.5.2.
( Name) ( Caption) Form1.
Properties
Caption , .
1.5.3. (Edit)
, ,
, Edit.
( String)
Text. Edit x, y, z (. . 1.4).


Standard , . Edit,
(. 1.1) Edit1, Edit2,
Edit3. , . ,
Edit ( Font).
Text x, y,
z.

14

,
x, y, z , Edit Text .
,
Edit.Text, ,
StrToFloat, x:=StrToFloat(Edit1.Text).
StrToInt. , , Windows ( ).
1 7.
1.5.4. (Label)
. 1.4 . Label. (
Standard). Caption ().
1.5.5. (Memo)

Memo (
Standard).
,
Properties
ScrollBars SSBoth. , Memo, Memo.Lines.
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.5.6. Close

, TBitBtn
Additional
TButton. 15

, Clyph.
, Kind, 11
. bkClose
.
1.5.7.
(FormCreate)
, , ( OnCreate). (TForm1.FormCreate).
Memo1. . ,

:
Procedure
TForm1.FormCreate(Sender:TObject). begin end
( , ).
1.5.8. (ButtonClick)
( Button),
Standart
. Caption.
.

Procedure TForm1.ButtonClick(Sender:TObject);
Begin
End;
(. 1).
! ButtonClick FormCreate
Delphi (
). , begin nd Delphi. .
, Additional BitBtn. Kind Close.
1.5.9.
, Run >Run
F9,

.
16

, , exe. (. 1.4).

. 1.4.
. x, y, z.
. Memo1 . x, y, z
Memo1 .

Close
, Delphi Run > Program Reset.
.
1.1 . , , , Delphi .
1.1.
unit Unit1;
interface
uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,
Controls,Forms,Dialogs,Buttons,StdCtrls;
type
17

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;
procedure TForm1.Button1Click(Sender: TObject);
var x,y,z,a,b,c,s:extended;
begin
x:=StrToFloat(Edit1.text);
y:=StrToFloat(Edit2.text);
z:=StrToFloat(Edit3.text);
a:=sqr(sin(x+y)/cos(x+y));
b:=abs(exp(3*y)-x*x);
c:=sqrt(arctan(z)+ln(x));
s:=a*b/c;
// memo1
Memo1.Lines.Add('x='+Edit1.Text+
'
y='+Edit2.Text+'
z='+Edit3.Text+
18

'

= '+FloatToStrF(s,fffixed,9,4));

end;
end.

19

2. OBJECT PASCAL
2.1. Object Pascal
Object Pascal :
1)
A, B, C, D,...,U, V, W, X, Y, Z;
a, b, c, d,...,u, v, w, x, y, z;
2) 0 9;
3) _ ,
4)
+
{} .
:
-
[ ] .
;
*
( ) .
'
/
#
@
=

$ .
>
.
^
<
,

:
:=
..
<=
>=
< >
(. .)
(* *)
5) () . , Begin, End;
6) . , Sin, Cos;
7) .
2.2.
,
. , () . , _ 127 ,
63 .
_. ,
20

. . ,
. Object Pascal
, , , , ,
nil.
263 263-1.
, 286; -17; +1995
.
( 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F ), $ (
36 )
, $3A4F; $100A
:
.
, , (
).
, -39.013; 0.256
,
: mEp, m ( ,
), E e
, p ( ).
, -7.78-3; -13e6; 4.9e5
: True
() False (). ,
.
, #.
, w; ; #53
,
.
, ''; #75#58#93
,
.
, [ 43, 76, 12, 90 ]; [ red, blue, green ]
.
.
:
Const <> = < >;
Const Min = 1;
//
Max = 150;
A=;

21

,
.
:
Var < 1, ... > : ;
, Var a, b: integer:
sum, min :extended;
c: Char;
, , ,
. Object Pascal . : () (). , (, )
. Type

Type <> = < >;
Object Pascal 7 (, , (), , , ,
-) 10 (, , , , , , , , , ).
Object Pascal ,
, ,
.
.
.
Unsigned ()
J

Byte
1
0 .. 255
Word
2
0 .. 65 535
Long,
4
0 .. 4 294 967 295
Cardinal

Single
4
Real, Double
8
Extended
10
Comp
8
Currency
8

ShortInt
SmallInt
Integer,
LongInt
Int64


7..8
15 .. 16
19 .. 20
19 .. 20
19 .. 20

. 2.1.
Signed ()

1
-128 .. 127
2
-32 768 .. 32 767
4
-2 147 483 648 ..
2 147 483 647
8
-263 .. 263-1
. 2.2.

1,5*10-45 .. 3,4*1038
5*10-324 .. 1,7*10308
3,4*10-4951 .. 1,1*104932
-263 .. 263-1
922 337 203 685 477, 5807
22

, a
. , Extended, (Double, Real, Single)
, ,
. Real
,
( 2 5 ) .
, Real. Boolean
(1 ), ByteBool (1 ), Bool (2 ), WordBool
(2 ) LongBool (4 ) Windows.

.
,
. :
Type < > = ( );
Var < 1,...> : < >;
Var < 1,...>: ( );
Type elem = (Fe, Cu, Na, Zn, Be);
Var a, b : elem;
Var a, b : (Fe, Cu, Na, Zn, Be);
a, b ,
. ,
. ,
Fe < Cu < Na < Zn < Be ( ).

, . :
Type < > = < 1>..< 2>;
Var < 1, ... > : < >;
Var < 1, ... > : < 1> .. < 2>;
< 1>, < 2> ,
,
.
.
, .
Type Dni = 1..31;
Var x, y : Dni;
x y Dni
1..31.
.
, , .
23

Const Min=1;
Max=31;
Type Dni = Min..Max;
Var x, y : Dni;
2.3. Object Pascal
, .
, , .
2.3.1.
:
< >:=<>;
:= ( ) .
,
<>. .
2.3.2.
begin end ( ).
2.4.

,
, .
: + (), - (), * ()
/ (). div
( ) mod ( ).
:
1. ;
2. , , div, mod;
3. .
.

Abs(x)
Pi
Sin(x)


/ .
.
/ .

2.3.

x

x
24

Cos(x)
Arctan(x)
Sqrt(x)
Sqr(x)
Exp(x)
Ln(x)
Trunc(x)
Frac(x)
Int(x)
Round(x)
Random
Random(x)
Odd(x)
Succ(x)
Pred(x)
Chr(x)
Ord(x)
Inc(x)
Dec(x)
Inc(x, n)
Dec(x, n)
A Div B
A Mod B

/
/
/
/
/
/

.
.
.
.
.
.
LongInt
.
.
LongInt

x
x
. x, x>0
x
. e x
. x, x>0
x
x
x
x

.
. .0<=<1
Word
Word
. .0<=<x

True,
x . (x )

. . x

. . x

(Byte)
. . ASCII x

(Byte) .ASCII x

. x 1

. x 1

. x n

x n
A B.
,
,
.

,
. 2.3 Object Pascal

.
:
tg ( x) si( x) / cos(x) ;

arcsi( ) arctg ( x /(1 x 2 )) ;


arccos(x)
/ 2 arcsi( ) ;
arcctg ( x)
/ 2 arctg ( x) ;

log a ( x) l( x) / l() ;

25

Object Pascal , x y :
x y = e y ln x = ex ( y l( x)) ;
.
. , ,
, . , ShortInt Word Integer.



, .
,
.
True () False (). : < (),
> (), = (), <= ( ), >= ( ), < > (
). :
Not > ;
And > ;
Or > .
Xor > .

:
1. Not;
2. *, /, Div, Mod, And, Shr, Shl ;
3. +, -, Or, Xor;
4. =, <>, <, >, <=, >=, in.
, ,
Ord(h), ch . Chr(< >)
.
ANSI - (American National Standart Institute). Pred(h) , ch .
Succ(ch) , ch .
, ch > a , <> ch, + <= ch.

26

3.

3.1.
, .
.
. 3.1
ax2+bx+c=0:
x1,2

b2 4ac
2a

a,b,c
d=b2-4ac

d>0

d=0

x=-b/(2a)

x1=(-b+d)/(2a)

x2=(-b-d)/(2a)

x1,x2

. 3.1.

27

Object Pascal
goto, if case.
3.2. goto
:
goto <>;
<> ,
label.
: labe1 8;

goto 8;

8: w:=exp(x);
goto . ,
goto, ,
. goto .
3.3. if
.
:
if <> then <1>
else < 2>;
( else-)
if <> then <>;
<> . ,
1, , , 2, ,
if. else (.
. 3.2 3.3).

. 3.2. if

28

. 3.3. if
if else then,
, (. . 3.4):
if <1> then if <2> then 1
else 2
else 3;

. 3.4. if
then else . , - . Object Pascal
begin ... end ( ). then
else.

29

3.4. Case
( ) ,
. ,
, , , , . Case :
case <> of
1: 1;
1: 1;

else 0;
end;
< > <> . <> < >, 0. case,
else- . case , .
3.5. , Delphi
Delphi
. ( ) . TCheckBox ,
.
CheckBox.Checked (true false). CheckBox,
,
CheckBox.Checked, if , :
if CheckBox.Checked then 1
else 2;
TRadiogroup . . (0, 1,
2, ...) Radiogroup.itemindex.
RadioGroup, ,
,
RadioGroup.ItemIndex , case , :
30

case radiogroup.itemindex of
0: w:=sin(x);
1:w:=ln(x);
2:w:=sqrt(x);
end;

31

4.

4.1.
() .
.
. . if
goto :
label m1;

m1: <1- >;

< >;
if < > then goto m1;
<1- >;
m1 , label.
, < >. m1 (<1- >). < > <1- >.
. , . .
, . Object Pascal :
repeat, while, for. .
4.2. repeat
:
repeat
< ( )>
until < >;
, repeat until ( ), , < >, .

32

, y=f(x) [a,b] h.
x:=a;
repeat
y:=f(x);
< x, y>
x:=x+h;
until x>b;
4.3. while
:
while < > do
begin
< ( >
end;
, begin end,
, < >. , < > ,
, repeat,
. ,
while
x:=a;
while x<=b do
begin
y:=f(x);
< x, y>
x:=x+h;
end;
4.4. for
:
for k:=m to n do
begin
< ( >
end;
k m n . , m>n, .
for k:=m downto n do
begin
< ( >
end ;

33

k. m<n,
. : k (, char, ,
). ! . .
, char:
Memo1:
var c: char;
...
For c:=z downto a do
Memo1.lines.add(c);

Break, .

Continue.

1. , .
2. ( ),
.
3. break.
4.
continue.
4.5.
, .
S(,n),
n

S ( x, n )
i 1

x 1
[a, b] h=(b-a)/m. a, b, i

n m.
h:=(b-a)/m;
x:=a;
repeat
s:=0;
for i:=1 to n do
s:=s+(x+1)/i;
< x, s>
until x>b+0.0000001;
,
, , h - 34

. , m+1 b b , . , x>b, b . , b x>b+0.0000001.


4.6.

0,1,2...n ,
ak=(ak-1). , a0. n, 0 , :
a:=a0;
for k:=1 to n do a:=f(a);
, n, 0 . ,
, ak a
0 . k
k
0 . a k a k 1

:
a:=a0; it:=0;
repeat
it:=it+1;
w:=a;
a:=f(a);
until (abs(a-w)<eps) or (it>100);
it , ,
,
.


. . S

a k ,

k 0

0, 1,......n, , k. ,
: ck=(ck-1),
= bk, bk k: bk=f(k). :

35

c:=c0
s:=c*f(0);
for k:=1 to n do
begin
c:=(c);
s:=s+c*f(k);
end;

36

5.


, , .
.:
1. ;
2. .
5.1.
, ,
,
. :
i:=2.5;

,
, .
, .
5.2.
, (:
, , . .), .
Delphi
, 50,
, . . Delphi
. ,
Delphi .
Delphi Stop on Delphi Exceptions Tools Debbuger Options Language Exceptions. Delphi .
. :
37

{$I-}
< >
{$I+}
{$I-} < >.
{$I+} .
5.3.

Object Pascal try...end; (except finally):
1- :
try
//
< >
except
// :
on < . 1> do < 1>;
...
on < . k> do < k>;
else
//
<
1 k >
end;
< >;
except else
on, do
-, , .
2- :
try
< >
finally
< , ,
>
end;
< >
< > .
, except < >, finally , finally.
, , finally , finally. exception -, < . > 38

, < >.
- ,
, else end.
else , , Delphi. , , . , ,
, .
, :
try
< >
except
<,
>
end;
finally , <>
. , , try...end.
5.4.
. 5.1

EAbort
, Abort
EArrayError
:
,
(
mxarrays)
EConvertError

EDivByZero

ERangeError

(
{$R+})
EIntOverflow
(
{$Q+})
EInvalidArgument
EZeroDivide

EOutOfMemory

39

EInvalidOp
EOverFlow
EAssertionFailed


Assert (
{ $+ })

5.5.

. :
-, Abort try EAbort. Break Exit, , , .
-, Assert (B:Boolean; [const st:String]),
EAssertionFailed,
B=false, ,
St ( ).
-,
raise < >. create ( ),
.
5.6. 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
(. 5.2).
. 5.2

mtWarning
-
mtError
mtInformation

mtConfirmation

40

mtCustom

Buttons ,
(. 5.3). .

mbYes
mbNo
mbOK

mbCancel
mbRetry
mbIgnore

mbAbort
mbHelp
mbAll

. 5.3
mbNoToAll
mbYesToAll

HelpCtx (
0).
, . , mr , : mrYes,
mrOK, mr Help.
5.7.
:

. 5.1.
unit Unit1;

5.1

interface
uses Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;
41

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
BitBtn1: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender:
procedure Button4Click(Sender:
procedure Button2Click(Sender:
procedure Button3Click(Sender:
private
{ Private declarations }
public
{ Public declarations }
end;
var Form1: TForm1;
implementation

TObject);
TObject);
TObject);
TObject);

{$R *.dfm}
{$R+}
procedure TForm1.Button1Click(Sender: TObject);
var a,b,c:extended;
//
/
begin
try
a:=StrToFloat(Edit1.text);
b:=StrToFloat(Edit2.text);
c:=a/b;
label2.Caption:=FloatToStrf(c,fffixed,8,2);
except
on EZeroDivide do MessageDlg(' ',
mtError,[mbOk],0);
on Econverterror do MessageDlg(''+
' edit',mtError,[mbOk],0);
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var a,b,c:byte;
// +
42

begin
try
a:=StrToInt(Edit1.text);
b:=StrToInt(Edit2.text);
c:=a+b;
label2.Caption:=IntToStr(c);
except
on Erangeerror do MessageDlg(' '+
' ',
mtError,[mbOk],0);
on Econverterror do MessageDlg(''+
' edit',mtError,[mbOk],0);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var a,b,c:byte;
// begin
try
a:=StrToInt(Edit1.text);
b:=StrToInt(Edit2.text);
c:=a-b;
label2.Caption:=IntToStr(c);
except
on Erangeerror do MessageDlg(' '+
' ',
mtError,[mbOk],0);
on Econverterror do MessageDlg(''+
' edit',mtError,[mbOk],0);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var a,b,c:byte; // *
begin
try
a:=StrToInt(Edit1.text);
b:=StrToInt(Edit2.text);
c:=a*b;
label2.Caption:=IntToStr(c);
except
on ERangeerror do MessageDlg(' '+
' ',
mtError,[mbOk],0);
43

on EConverterror do MessageDlg(''+
' edit',mtError,[mbOk],0);
end;
end;
end.

44

6.

6.1.
: , , . ,

c (c1, c2,, cn), ,


,
. (ij, i=1,..,n, j=1,..,m), i
, j .
,
. ,

c b

ci bi
i 1

A c , bi

aij c j ;
j 1

aik qkj ;

A G, d ij
k 1


,
. Object Pascal
.
.
array :
Type < >=array[ ] of < >;
Var a, b, c:< >;
, , , . . . ( ), :
b[1]:=5; c[k]:=a[k-2]+b[4*k+3];
a .
Type vek=array[1..100] of extended;
mat=array[1..20,1..20] of extended;
Var a, b: vek;
45

w :mat;
c: array[byte] of char;
a, a . : =b e true,
b false , :=b;
b.
6.2. Delphi
, ()
, .
, . :
Memo a n m.
, :
4 5
n m
0.1 0.2 0.8 1.2 5.6 1-
1.8 2.1 4.2 6.3 2.5 2-
0.8 0.2 0.6 1.2 1.4 3-
4.1 7.3 5.8 3.2 1.5 4-
Prg.dat . :
Type mat=array[1..10,1..10] of extended;
Var a:mat;
Lr:TextFile;// ;
St:String;
begin
AssignFile(Lr,Prg.dat);
Reset(Lr);
Readln(Lr,n,m); // n m 1-
for i:=1 to n do
begin
st:=;
for j:=1 to m do
begin
Read(Lr,a[i,j]); // i-
st:=st+ +FloatToStrF(a[i,j],fffixed,6,1);
end;
Readln(Lr); //
Memo1.Lines.Add(st); // Memo
46

end;
Delphi
StringGrid ( Additional),
, (
Edit).

StringGrid1.Cells:array[0..ColCount-1,0..RowCount-1] of string;
ColCount RowCount,
, . Cells
,
. a,
:
n:=4; m:=5;
StringGrid1.ColCount:=m;
StringGrid1.RowCount:=n;
...
Procedure Tform1.Button5Click(Sender:Tobject);
Begin
for i:=1 to n do // stringgrid1
for j:=1 to m do
a[i,j]:=StrToFloat(StringGrid1.Cells[j-1,i-1]);
//
...
for i:=1 to n do // stringgrid1
for j:=1 to m do
StriGrid1.Cells[j-1,i-1]:=FloatToStrF(a[i,j],fffixed,8,3);
end;

. , Cells , ( ), ,
, .
6.3.
n :
S:=0; for i:=1 to n do S:=S+a[i];
:
S:=0;
for i:=1 to n do
for j:=1 to m do
S:=S+abs(b[i,j]);
47

:
p:=1;
For i:=1 to n do
p:=p*b[i,i];
c:
max:=a[1];
for i:=2 to n do
if a[i]>max then max=a[i];
:
m:=1;
for i:=2 to n do
if a[i]>a[m] then m:=i;
1 2:
for j:=1 to m do
begin
r:=a[k1,j];
a[k1,j]:=a[k2,j];
a[k2,j]:=r;
end;
:
for i:=1 to n-1 do
for k:=1 to n- i do
if a[k]>a[k+1] then
begin
r:=a[k];
a[k]:=a[k+1];
a[k+1]:=r;
end;

48

7.

7.1.
. .

.
Object Pascal
,
,
. .
7.2.

,
. . 4 , . ^, pointer.
:
Type vec=array[1..1] of extended;
mat=array[1..1,1..1] of extended;
ps=String [20];
Var a: ^vec;
w: ^mat;
s: ^ps;
p, q: pointer;
p, q ; , w, s , . . , , , .
, . , :
p:=q;
, . ,
, , :
p:=a; w:=p;
49

: s^:=; (=) (<>). , , (). Addr(): p:=Addr(m);


c @: p:=@m; nil: p:=nil;
7.3.
Heap .
, New GetMem. New(a:pointer); ,

. a^. .
, , Dispose(a); GetMem(a:pointer; size:Word);
FreeMem(a:pointer; size:Word);, size ,
, a. ,
8- . .
7.4.

. Getmem Freemem
.
, :
Type vek=array[1..1] of < >;
Var a:^vek; //
...
// n
getmem(a, n* sizeof(< >));
...
//
freemem(a,n* sizeof(< >));
sizeof(<>)
.
Delphi 4, Object Pascal
, :
50

Var a: array of extended;


//
b: array of array of integer; //

SetLength( ,
). SetLength(a, n) a , . .
n extended.
0, n-1.
, , . .
b (, n m
) :
SetLength(b, n);
For k := 0 to n-1 do
SetLength(b[k], m);
,
, :
SetLength(b, n);
For k := 0 to n-1 do
SetLength(b[k], k+1); //

SetLength(b, 3);
SetLength(b[0], 8); // 1- 8
SetLength(b[1], 2); // 2- 2
SetLength(b[2], 4); // 3- 4
.
Finalize(< >); <
>:= nil; SetLength()
. , .
SetLength() ,
, .
, . Object Pascal Low(), High(), Copy(). Low(< >) High(< >)
, . . 0 -1 . High()
-1. copy() :
Copy(< >, < >,
< >);
51

52

8.
8.1.
,
.
.
, , , , , . Object Pascal -
-.
Function < >( ): ;
< >
Begin
< >
End;

Procedure < >( );
< >
Begin
< >
End;
, :
x, y : extended; var m, k : integer; const s : string; out : extended
, .
, result,
< >. . result
, result .
:
< >(< >);
< >
, , . return exit.
53

8.2.
,
.

, , , . . , , ( ).
, , , , . . , . .

:
-,
-,
, .
- : : . -

. , , . , ,
. , ,
, , . . ,
, . -
, , , - . - var : var : . 4 . . , , .
. - const : const : .
- ,
. . out : out : . -, 54

. . , . . - , :
Type < ->=function ( ):
;
< ->=procedure ( );
:
: < -> : < ->.
, . register, . forward , , .
8.3.
,
.
,
, ,
. Object Pascal . (unit) -
, . 8.1. , , .
, , , . ,
, , , . , (initialization) (finalization) , , , .
unit < >;
interface
< , ,
>
implementation
<, >

55

Initialization
Finalization
end.
. 8.1.
, . uses < >;
.
Delphi File >New Unit.
,
Save As Add to Project Project.
8.4.
rex(x)=x/7+cos(x2),
fox(x)=ln(x2+5)+sin(x/3)
f(x) [a, b] h TMemo.
unit biblio;

8.1
interface
uses SysUtils,StdCtrls;
type fun=function(x:extended):extended;
function rex(x:extended):extended;
function fox(x:extended):extended;
procedure tab(a,b,h:extended; f:fun; mem:TMemo);
implementation

function rex;
begin
result:=x/7+cos(x*x);
end;
function fox;
begin
result:=ln(x*x+5)+sin(x/3);
end;
procedure tab;
var x:extended;
begin
x:=a;
mem.clear;
repeat
56

mem.lines.add(' '+floattostrf(x,fffixed,6,2)+
'
'+ floattostrf(f(x),fffixed,9,6) );
x:=x+h;
until x>b+0.00000001;
end;
end.
unit Unit1;

8.2

interface
uses Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls,
biblio;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var z:extended;
begin
tab(0, 1, 0.1, rex, memo1);
tab(2, 3, 0.1, fox, memo2);
end;
end.

57

9.

9.1.

. ={ 1, 2, ..... n}
. , :
={ 2, 4, 1, 5}, ={ 4, 1, 3}, .... .
Object Pascal , :
Type < > = set of < >;
Var < > : < >;
< > , word, integer, longint, .
. (, , char, byte, boolean). 256.
, .
. , , . 0. :
type sim=set of char;
var a, b : set of (a..z);
c, d : sim;
e, g : set of byte;
c:=[, +, 7];
g:=[14, 2, 30];
d:=[];

9.2.
:
(+): D=A+B={ 1, 2, 3, 4, 5},
D , .
( ) (-): =-={ 2, 5},
, .
(*): F=A*B={ 1, 4}, F
, .
(=): =, true,
.
(<>): <> , true .
58

(<=): A<=B, true,


.
(>=): A>=B, true,
.
(in): in A, true,
.
:
Include (s, i); s i;
Exclude (s, i); s i.
i . ,
s:=s+[i]; s:=s - [i];

. :
1. : if (k=5) or (k=1) or (k=8) or (k=12) then . . .
if k in [5, 1, 8, 12] then . . .
2. a
w:=a*[a..z];
3. a
w:=a-[a..z];
9.3.
. (. 9.1).

59

. 9.1.
unit Unit1;

9.1

interface
uses Windows,Messages,SysUtils,Variants,Classes,
Graphics,Controls,Forms,Dialogs,StdCtrls,Buttons;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
BitBtn1: TBitBtn;
Memo1: TMemo;
procedure FormActivate(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject; var
Key: Char);
procedure ComboBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

60

var

Form1: TForm1;
implementation

{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
combobox1.setfocus;
memo1.Clear;
end;
procedure TForm1.ComboBox1KeyPress(Sender: TObject;
var Key: Char);
begin
if key=#13 then
begin
combobox1.items.add( combobox1.text);
combobox1.text:='';
end;
end;
procedure TForm1.ComboBox1Click(Sender: TObject);
//
const c : set of char = [' ', '.', ',', ':', ';',
'(', ')', '?', '!' , '[', ']', '{', '}'];
var s : string;
n,k,i : integer;
a : array of string;
begin
s:= combobox1.text+' '; n:=0; memo1.clear;
while s<>'' do
begin //
while (s<>'') and (s[1] in c) do delete(s,1,1);
if s<>'' then
begin
for k:=1 to length(s) do
if s[k] in c then break;
inc(n);
setlength(a,n);//
a[n-1]:=copy(s,1,k-1);
delete(s,1,k);
end;
end;
61

//
for i:=2 to n do
for k:=0 to n-i do
if a[k]>a[k+1] then
begin
s:=a[k];
a[k]:=a[k+1];
a[k+1]:=s;
end;
for k:=0 to n-1 do memo1.lines.add(a[k]);
a:=nil; //
end;
end.

62

10.

10.1.

, 255 . : var : string[n]; n255
var : shortstring; -
, - var : string[255];

(), ( 2
) .
: var : string;

,
, (ansi- 256 , , ,
). : var
: wideString;
-
, #0. :
var : PChar; -
API- .
Delphi
.
, .
10.2.

(:=), (+) (=, <>, >, <, >=, <=). .
.
, ,
,
. : ax < bcd < b,
63

> >. .
10.3.
Delphi , .
.

Delete(s : string; pz, n : integer); n


s, pz, : s:=florex; Delete(s, 4, 2);
s=flox.
Insert(w, s : string; pz : integer); w
s, pz, : s:= ; Insert( ,
s, 5); s= .
Str(x[: : . . ]; s : string);
( ), : x:=25.4e-1; k:=86;
Str(x:8:4, s); s= 2.5400
Str(x, s);
s=2,540000e+00
Str(k:3, s);
s= 86
Val(s : string; x : (. ); Kod : integer);
s
, Kod , Kod = 0 ,
Kod= , , :
s1:=2e-5; s2:=468; s3=0..256
Val(s1, x, kod); =2 10-5, kod = 0
Val(s2, x ,kod); x=468,
kod = 0
Val(s3, x, kod); x , kod=3

Copy(s, pz, n) s n ,
pz, s , :
s:=d:\pas\prog.pas; sp:=Copy(s, 8, 4);
sp=prog.
length(s) s.
pos(sp,s) , s sp, sp ,
= 0, : pz:=pos(pas, s); // s
pz=4.
strToFloat(s)
( Val).
strToInt(s) .
64

floatTostrF(x, fffixed, 8, 4) -
: 8 : 4, ( str).
intTostr(m) ,
.
10.4.

function zam( s : string) : string;
var k: word;
begin
for k:=1 to length (s) do
if s[k]= then s[k]:=;
result:=s;
end;

function kol( s : string) : byte;
var k:word;
begin
result:=0;
for k:=1 to length(s) do
if s[k] in [0..9] then inc(result);
end;

65

11.

11.1.
, , . :
Type < >=record
1: 1;
2: 2;
...
End;
Var < >=< >;

Type =record
1: 1;
2: 2;
...
case of
1:( 01: 01;
02: 02);
...
end;
end;
.
. case < > of, .
,
, , ,
case. ,
.
, (
) (
).
11.2.
(:=), : a:=b; a
b.
,
( ), :
type stud=record
fam:string[20];
gr:integer;
66

oc:array[1..5] of byte;
sr:extended;
end;
var a, b:stud;
w:array of stud;
...
a.fam:=; a.gr:=123201; a.oc[1]:=7; w[1].fam:=;
, , ( ),
. ,
With < > do
begin
< >
end;
, with a do begin fam:=; gr:=123201; oc[1]:=7; end;
,
.
Type zap=record
Case boolean do
true: (a:array[1..4] of integer);
false:(b:array[1..2,1..2] of integer);
end;
Var w:zap;
...
for k:=1 to 4 do w.a[k]:=k;
w.b[2,1] 3.
.

67

12.

12.1.
.
( ) .
Object Pascal .
(, , ). , , ,
. , , . ( ) , . Delphi :
Var
< >: file of < >;//
< > : TextFile; //
< > : File;
//
, ,
,
:
0

BO
F

1
1

.....

n-2

n-1

EF


n .

, . BOF (Begin of File),


, , . ., EOF
(End of File). , BOF EOF , . , ( ),
.
68

12.2.
12.2.1.
f , x, y,
z , .
Var f : file of < >;
x, y, z : < >;
: AssignFile(f,
< >); Reset(f); Rewrite(f); AssignFile() f < > ( ). Reset(f) Rewrite(f) () . , Rewrite(f),
< >. < >,
Reset(f). ( 0). Rewrite(f),
(.. ). ,
.
Write(f, x); Write(f, x, y, z); ,
. ,
. , , FileSize(f).
Read(f, x);
Read(f, x, y, z); . , ,
. , ,
Eof(f), True, , False, . , , : if not Eof(f) then
Read(f, x);
.
Seek(f, < >). ,
Seek(f, 2); Read(f, x); Write(f, y); x 2 (), y 3 ().
FilePos(f).
Clo69

seFile(f). , -
, , , .
12.2.2.
, . . , Object Pascal
.
,
.
, . .
() EOLN (End of LiNe),
EOF (End of File).

, . , ,
Reset (ft) : Read(ft, w);
, Readln(ft, a, b, c);
(), Readln(ft); () (ft , w char, a, b, c string).
Rewrite (ft) , .
Append (ft).

() .
Write(ft, a, b);, Writeln(ft, c:8, d=, d:10:2);
Readln(ft), Writeln(ft),
, Writeln
EOLN. , a, b, c
.
. , .
12.2.3.
: var fn: File; Reset(fn, size)
Rewrite(fn, size), size .
.
,
.

70

12.3.
AssignFile(var F; FileName: string) F
FileName ( ).
Reset(var F[: File; RecSize: word]) .
RecSize .
Rewrite(var F[: File; RecSize: word]) .
Append(var F: TextFile)
.
Read(F,v1[,v2, vn]) , .
Write(F,v1[,v2,vn]) , .
CloseFile(F) .
Rename(var F; NewName: string)
.
Erase(var F) .
Seek(var F; NumRec: Longint) NumRec.
Truncate(var F) , .
IoResult: integer -.
FilePos(var F): longint
. .
FileSize(var F): longint .
Eoln(var F: TextFile): boolean True,
.
Eof(var F) ): boolean True, .
SeekEoln(var F: TextFile): boolean True, , .
SeekEof(var F: TextFile): boolean , SeekEoln,
.
12.4. OpenDialog SaveDialog
Delphi
,
. ,
OpenDialog1.FileName SaveDialog1.FileName, AssignFile().
OpenDialog SaveDialog Dialogs
. , . .
.
71

.
.
,
.
FileName.
, ,
Filter, , , , DefaultExt. , , , dat, DefaultExt
SaveDialog dat (
txt). Title.

12.5.
, .
, ,
.

. 12.1.

72

. 12.2.

. 12.3. SaveDialog1 .

73

. 12.4. .

. 12.5. .

74

. 12.6. .

. 12.7. , .
unit Unit1;

12.1
interface

uses
75

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
BitBtn1: TBitBtn;
Panel1: TPanel;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button3: TButton;
Button4: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Panel2: TPanel;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Panel3: TPanel;
Button9: TButton;
Button10: TButton;
Edit3: TEdit;
Label3: TLabel;
Panel4: TPanel;
Label4: TLabel;
Label5: TLabel;
Memo1: TMemo;
Memo2: TMemo;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
private
{ Private declarations }
76

public
{ Public declarations }
end;
type book=record
avt:string[20];
naz:string[30];
end;
var
Form1: TForm1;
f:file of book;
w:book;
a:array[1..100] of book;
fname:string;
n,i,k:integer;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
panel1.Hide; panel2.Hide;
panel3.Hide; panel4.Hide;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//
SaveDialog1.Title:=' ';
if SaveDialog1.Execute then
begin
fname:=SaveDialog1.FileName;
AssignFile(f,fname);
Rewrite(f);
end;
Panel1.Show;
Button1.Hide;
Button2.Hide; BitBtn1.Hide;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
//
w.avt:=edit1.text;
w.naz:=edit2.text;
write(f,w);
77

edit1.clear;
end;

edit2.clear;

procedure TForm1.Button4Click(Sender: TObject);


begin
//
CloseFile(f);
panel1.Hide;
panel2.show;
BitBtn1.show;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
//
reset(f); n:=0;
while not eof(f) do
begin
n:=n+1;
read(f,a[n]);
end;
closeFile(f);
for i:=1 to n-1 do
for k:=1 to n-i do
if a[k].avt > a[k+1].avt then
begin w:=a[k]; a[k]:=a[k+1]; a[k+1]:=w; end;
rewrite(f);
for i:=1 to n do write(f,a[i]);
closeFile(f);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
//
panel4.Show; memo1.clear; memo2.clear;
reset(f);
while not eof(f) do
begin
read(f,w);
memo1.lines.add(w.avt);
memo2.lines.add(w.naz);
end;
closeFile(f);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//
78

OpenDialog1.Title:=' ';
if OpenDialog1.Execute then
begin
fname:=OpenDialog1.FileName;
AssignFile(f,fname);
Reset(f);
end;
Panel2.Show;
Button1.Hide;
Button2.Hide; BitBtn1.Hide;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
// panel2
Button1.show;
Button2.show; BitBtn1.show;
panel2.Hide;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
//
panel2.Hide;
panel3.Show;
bitbtn1.Hide;
memo1.clear;
memo2.clear;
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
//
memo1.clear; memo2.clear;
reset(f);
while not eof(f) do
begin
read(f,w);
if w.avt=edit3.text then
begin
memo1.lines.add(w.avt);
memo2.lines.add(w.naz);
end;
end;
closeFile(f);
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
// panel3
panel3.Hide;
panel4.Hide;
Button1.show;
Button2.show;
BitBtn1.show;
end; end.
79

13.


, . ,
.
.
- , , ,
( , , ). .
. .
13.1.
Delphi
( , TPaintBox), TImage ( Additional ). Image1 ,
ClipBoard.Assign(Image1.Picture) ( Clipbrd).
Tanvas, , . (x, y), x
, , y , .
(0, 0), (Image1.Width-1, Image1.Height-1).
TCanvas
Property Pen : TPen; . , Color
- , Width - Style ( psSolid , psDash , psDot , psClear .).
Property Brush : TBrush; . . , Color - Style
( bsSolid , bsCross , bsClear .).
Property Font : TFont; . , Color , Size - Style ( fsBold , fsitalic .).

80

TCanvas
Pdure llis(1, Y1, 2, Y2: Integer) (X1, Y1), (2, Y2)
.
Pedure Line (X, : Integer)
(X. ).
Procedure v(, : Integer) (X, )
.
Pedure lgn (ints: rr f int)
, ints.
: Canvas.Polygon([Point(x1, y1), Point(x2, y2), Point(x3, y3]); .
lline.
Pedure Rectangle (X1, 1, 2, 2: Integer) (X1, 1), (2, 2).
FrameRect lLine.
Procedure tut (, : Integer; const t: String) t , ,
, (X, ).
13.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).
. sin(x) cos(x) Chart. .
81

. 13.1. chart
unit Unit1;

13.1

interface
uses Windows,Messages,SysUtils,Variants,Classes,
Graphics,Controls,Forms,Dialogs,StdCtrls,TeEngine,
Series, ExtCtrls, TeeProcs, Chart, Buttons;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TLineSeries;
Series2: TLineSeries;
Button1: TButton;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
f:file of extended;
82

implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var k:integer; //
x,y,z:extended;
begin
for k:=0 to 100 do
begin
x:=0.02*pi*k; y:=sin(x); z:=cos(x);
series1.AddXY(x,y,'',clRed);
series2.AddXY(x,z,'',clGreen);
end;
end;
end.
.

. 13.2.

unit Unit1;

13.2
83

interface
uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,
Controls,Forms,Dialogs,StdCtrls,Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
with form1.Canvas do
begin
pen.Width:=3;
pen.color:=clred;
brush.style:=bsCross;
brush.Color:=clgreen;
polygon([point(190,30), point(240,60),
point(170,40)]);
polyline([point(290,30), point(340,60),
point(270,40)]);
rectangle(200,100,280,140);
ellipse(20,150,220,220);
font.color:=clblue;
font.Size:=50;
textout(350,120,'test');
end;
end;
84

procedure TForm1.Button2Click(Sender: TObject);


begin
//
refresh;
end;
end.

85

14.

14.1.
, .
,
.
: n! = 1*2*3(n-1)*n.
: n! = (n-1)! * n, 0! = 1.
:
Function fak(n:word):extended;
begin
if n=0 then result:=1
else result:=fak(n-1)*n
end;
: (extended) -
n!.
:
Function fak(n:word):extended;
Var k:word;
begin
result:=1;
if n>1 then for k:=2 to n do
result:=result*k;
end;

, ,
( , n=0). ,
( EStackOverFlow), . . ( )
. , n-
n+1 .
, , . , ,
.
86

//
Procedure rex(< >); Forward;
Procedure fox(< >);
begin
...
rex(< >);
...
end;
Procedure rex;
begin
...
fox(< >);
...
end;
rex() ,
, Object Pascal.

Forward.
. , . . , .
15.2.
max (a1an) = max ( max ( a1an/2 ), max ( an/2+1an ) )
type vek=array[1..50] of extended;
function
maxR(x:vek; m,n:integer):extended
var k:integer;
begin
if m=n then result:=x[m]
else begin
k:=(m+n) div 2;
if maxR(x,m,k)>maxR(x,k+1,n)
then result:=maxR(x,m,k)
else result:=maxR(x,k+1,n);
end;
end;

87

max (a1an) = max ( max(a1an-1), an)


function maxRn(x:vek; n:integer):extended;
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;

88

15.
15.1.

.
. , , . :
1. , ,
(, ) ,
.
2. ( ) ,
, . .
, .
(), . , , , .
,
. , ,
, . . -
, .
15.2.
a[i], i = 1,.., n i, a[i].k = isk.
k , isk . i a[i].
() , . , :
i:=1;
while (i<=n) and (a[i].k <> isk) do i:=i+1;
if i=n+1 then < ( )>
else <( = , i)>;
. , .
89

, .
.
(, ) . .
.
a[n+1].k := isk; i:=1;
while a[i].k <> isk do i:=i+1;
if i=n+1 then <( ) >
else <( = , i) >;
( ) , k, . . a[i]. k a[i+1]. k.
(m-) . a[m].k < isk,
i m , a[m]. k isk,
i > m:
i:=1; j:=n;
while i < j do
begin
m := ( i+j ) div 2;
if a[m].k < isk then i:=m+1 else j:=m;
end;
if a[i].k = isk then <( = , i) >
else <( ) > ;
a[m].k =
isk. , ,
i=j.
15.3.
, .
. , . , . . .
e (), .
.
. (n),
(n) n. ( )
( n
) n log n , (2
) n .
90

, . , , ,
, ,
n (n 50) . ~
( n/log(n) ) n 100.
:
1) ( ).
2) .
3) () .
4) ( ).
:
1) . ,
.
2) , HeapSort, . .
3) , QuickSort, . , .
. ,
n>100 , QuickSort 2 3
, HeapSort, 3 7 , .
.
15.3.1.

. ,
. .

, .
type vec = array[1..100] of extended;
ind = array[1..100] of integer;
Procedure PuzSort(var a:vec; n:integer);
var k,kol:integer; //
w:extended;
p:boolean;
begin
kol:=1;
repeat
p:=true;
for k:=1 to n-kol do
91

if a[k]>a[k+1] then
begin
w:=a[k];
a[k]:=a[k+1];
a[k+1]:=w;
p:=false;
end;
inc(kol);
until p;
end;
n1 . ,
,
(for kol := 1 to n 1 do), repeat p.
15.3.2.
. (k-)
- n- , - .
Procedure PramSort(var a:vec; n:integer);
var k,i,m:integer;
w:extended;
begin
for k:=1 to n-1 do
begin
m:=k;
for i:=k+1 to n do
if a[i]<a[m] then m:=i;
w:=a[m]; a[m]:=a[k]; a[k]:=w;
end;
end;
15.3.3.
, .
, . kol , . kol . kol ,
, .

92

Procedure ShellSort(var a:vec; n:integer);


var k,kol:integer; //
w:extended;
p:boolean;
begin
kol:=n div 2; //
repeat
repeat
p:=true;
for k:=1 to n-kol do
if a[k]>a[k+kol] then
begin
w:=a[k];
a[k]:=a[k+kol];
a[k+kol]:=w;
p:=false;
end;
until p;
kol:=kol div 2;
until kol=0;
end;
:
. . .
type ind=array[1..100] of integer;
Procedure ShellSortInd(a:vec; n:integer; var nom:ind);
var k,kol,w:integer;
p:boolean;
begin
for k:=1 to n do nom[k]:=k;
kol:=n div 2; //
repeat
repeat
p:=true;
for k:=1 to n-kol do
if a[nom[k]]>a[nom[k+kol]] then
begin
w:=nom[k];
nom[k]:=nom[k+kol];
nom[k+kol]:=w;
p:=false;
93

end;
until p;
kol:=kol div 2;
until kol=0;
end;
15.3.4. (Hoare)
. , , ,
, , . , : ,
, , .
, , . , . ,
.
. .

Procedure QuickSort(var a:vec; low,high:integer);
var l,r:integer; //
op,w:extended;
begin
op:=a[(low+high) div 2]; //
// , , , -
l:=low; r:=high;
repeat
while (l<=high) and (a[l]<op) do inc(l);
while (r>=low) and (a[r >op) do dec(r);
if l<=r then begin
w:=a[l]; a[l]:=a[r]; a[r]:=w;
inc(l); dec(r);
end;
until l>r;
if r>low then QuickSort(a,low,r);
if l<high then QuickSort(a,l,high);
end;

94

16.

16.1.
, . : ,
, .
.
: , , . , .
.
(),
:
, , , .
. . , ,
(), .
, , , . .
16.2.
, ,
,

. avs nvs
:
Type Tspis=integer; //
var a:array of Tspis; //
procedure addvec(avs:Tspis; nvs:integer);
begin // avs nvs-
setlength(a,high(a)+2); //
for k:=high(a)-1 downto nvs do a[k+1]:=a[k]; //
a[nvs]:=avs;
//
end;
95

, setlength() .
16.3.
nyd , , , . . (nyd+1)- , nyd- . ;
procedure delvec(nyd:integer);
begin
for k:=nyd+1 to high(a) do a[k-1]:=a[k]; //
setlength(a,high(a)); //
end;
,
:
, ,
.
16.4.
. Button1
minmax ( Edit1,
Edit2) , . , Button1, .
Button2 ,
Edit3.

96

. 16.1.
unit Unit1;

16.1

interface
uses Windows,Messages,SysUtils,Variants,Classes,
Graphics,Controls,Forms,Dialogs,Buttons,StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
97

{ Private declarations }
public
{ Public declarations }
end;
type Tspis=integer; // .
var
Form1: TForm1;
a:array of Tspis; // .
k:integer;
implementation
{$R *.dfm}
procedure addvec(avs:Tspis; nvs:integer);
begin // avs nvs-
setlength(a,high(a)+2);//
for k:=high(a)-1 downto nvs do a[k+1]:=a[k];
a[nvs]:=avs;
end;
procedure delvec(nyd:integer);
begin // nyd-
for k:=nyd+1 to high(a) do a[k-1]:=a[k];
setlength(a,high(a));//
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if (edit1.text='') or (edit2.text='') then
button1.enabled:=false;
if edit3.text='' then button2.enabled:=false;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if (edit1.text<>'') and (edit2.text<>'') then
button1.enabled:=true;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
if (edit1.text<>'') and (edit2.text<>'') then
button1.enabled:=true;
end;
98

procedure TForm1.Edit3Change(Sender: TObject);


begin
if edit3.text<>'' then button2.enabled:=true;
end;
procedure TForm1.Button1Click(Sender: TObject);
var min,max,n:integer;
//
w:Tspis;
begin
min:=strtoint(edit1.text);
max:=strtoint(edit2.text);
randomize;
w:=min+random(max-min+1); //
if high(a)=-1 then
begin setlength(a,1); a[0]:=w;end;//
else
begin
n:=high(a)+1;
for k:=0 to high(a) do//
if w<a[k] then begin n:=k; break; end;
addvec(w,n); //
end;
memo1.clear;
for k:=0 to high(a) do
memo1.Lines.Add(inttostr(k+1)+'.'+inttostr(a[k]));
end;
procedure TForm1.Button2Click(Sender: TObject);
var n:integer; //
begin
n:=strtoint(edit3.Text)-1;
if n>high(a) then
begin
edit3.Clear; button2.enabled:=false; exit;
end;
delvec(n); // n-
memo1.clear;
for k:=0 to high(a) do
memo1.Lines.Add(inttostr(k+1)+'.'+inttostr(a[k]));
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
99

begin
a:=nil; //
end;
end.

100

17.

17.1.

.
, , , (). , , . . Object Pascal
,
() ( ) , (. . ) .
, .
.
.
( ).
, . , ,
, . .
. ( ), ( ). ,
.
, , , , .
, .
17.2.
:
Type Tinf=integer; //
TSel=^Sel; //
Sel=record
inf : Tinf;
a : TSel;
101

end;
Tinf ,
. .
. , TSel (a:TSel), . . . a . inf , , ,
inf, , .
key:Tkey, .
:
TSel, a
(. 17.1):
sp1

sp2

sp3

sp k-1

sp k

a1

a2

a3

ak-1

ak

inf1

inf2

inf3

infk-1

infk

17.1.
sp1, sp2, , spk.

. , sp2,
, ( sp1^.a:=sp3; dispose(sp2);) (. .
17.2).
sp1

sp2

sp3

sp k-1

sp k

a1

a2

a3

ak-1

ak

inf1

inf2

inf3

infk-1

infk

17.2.
102

sp1 sp2, , , ,
(new(sp); sp^.inf:=inf;
sp1^.a:=sp; sp^.a:=sp2;) (. . 17.3).

sp1

sp2
a1

a2

inf1

inf2
a
inf

. 17.3.
spk^.a:=nil;
, 1- ( . 17.1) w:=sp1;, w1:=sp1;
( ) wk:=spk; .
. , ,

Type
Tinf=integer; //
TSel=^Sel;
Sel=record
inf:Tinf;
a:TSel;
end;
var k,n,kol:integer;
w,t:TSel;
begin
n:=strtoint(edit1.Text); //
w:= nil; Randomize; //
for k:=1 to n do
103

begin
New(t);
//
t^.inf:=random(101)-50; //
t^.a:=w; //
w:=t;
//
end;
ListBox1.Clear;
t:=w; kol:=0;
while t<>nil do
begin
k:=t^.inf; // .
ListBox1.items.add(inttostr(k));
if k>0 then inc(kol);
t:=t^.a;
//
end;
label1.Caption:='. . = ' +inttostr(kol);
end;
, ,
List1S, .
17.3.

procedure AddStek(var w:TSel; inf:Tinf);
var t:TSel;
begin
New(t);
//
t^.inf:=inf; //
t^.a:=w; //
w:=t;
//
end;
n- ( )
procedure ReadStek(w:TSel; n:integer; var inf:Tinf);
var i:integer;
t:TSel;
begin
if w=nil then exit;
t:=w;
// =
for i:=1 to n do
begin
inf:=t^.inf;
104

t:=t^.a;
end;
end;

//

( 1- )
procedure DelLast(var w:TSel; var inf:Tinf);
var t:TSel;
begin
if w=nil then exit; //
inf:=w^.inf;
t:=w;
//
w:=w^.a; //
dispose(t); //
end;

procedure DelStek(var w:TSel);
var inf:Tinf;
begin
while w<>nil do DelLast(w,inf);
end;
ListBox
procedure WrtStek(w:Tsel; LS:TListBox);
var t:Tsel;
begin
LS.clear;
t:=w;
// =
while t<>nil do
begin
LS.Items.Add(intToStr(t^.inf));
t:=t^.a; //
end;
end;
, sp
procedure RevAfter(sp:TSel);
var t:TSel;
begin
t:=sp^.a^.a;
sp^.a^.a:=t^.a;
t^.a:=sp^.a;
sp^.a:=t;
105

end;
sp

Procedure Revinf(sp:TSel);
var inf:Tinf;
begin
inf:=sp^.inf;
sp^.inf:=sp^.a^.inf;
sp^.a^.inf:=inf;
end;

procedure SortAfter(var w:TSel);
var p,t:Tsel;
inf:Tinf;
begin
if (w=nil)or(w^.a=nil) then exit; // 1
AddStek(w,0); //
t:=nil;
repeat
p:=w;
while p^.a^.a<>t do
begin
if p^.a^.inf>p^.a^.a^.inf then RevAfter(p);
p:=p^.a;
end;
t:=p^.a;
until w^.a^.a=t;
DelLast(w,inf); //
end;

procedure Sortinf(w:TSel);
var p,t:Tsel;
begin
if (w=nil)or(w^.a=nil) then exit; // 1
t:=nil;
repeat
p:=w;
while p^.a<>t do
begin
if p^.inf>p^.a^.inf then Revinf(p);
p:=p^.a;
106

end;
t:=p;
until w^.a=t;
end;
17.4.

procedure AddBeg(var w1,wk:TSel; inf:Tinf);
var t:TSel;
begin
if w1=nil then begin //
new(w1);
w1^.inf:=inf;
w1^.a:=nil;
wk:=w1;
end
else begin
new(t);
t^.inf:=inf;
t^.a:=w1;
w1:=t;
end;
end;

procedure AddEnd(var w1,wk:TSel; inf:Tinf);
var t:TSel;
begin
if wk=nil then begin //
new(wk);
wk^.inf:=inf;
wk^.a:=nil;
w1:=wk;
end
else begin
new(t);
t^.inf:=inf;
t^.a:=nil;
wk^.a:=t;
wk:=t;
end;
end;
107

sp
procedure AddAfter(sp:TSel; inf:Tinf);
var t:TSel;
begin
if sp^.a=nil then exit; //
new(t);
t^.inf:=inf;
t^.a:=sp^.a;
sp^.a:=t;
end;

procedure DelBeg(var w1,wk:TSel; var inf:Tinf);
var t:tsel;
begin
if w1=nil then exit; //
inf:=w1^.inf;
t:=w1;
w1:=w1^.a; // -
dispose(t); //
if w1=nil then wk:=nil;
end;
sp
procedure DelAfter(sp:TSel; var inf:Tinf);
var t:tsel;
begin
//
if (sp^.a=nil) or (sp^.a^.a=nil) then exit;
t:=sp^.a;
//
inf:=t^.inf; //
sp^.a:=t^.a; // .
dispose(t); //
end;

procedure DelSpis(var w1,wk:TSel);
var a:Tinf;
begin
while w1<>nil do DelBeg(w1,wk,a);
end;
108

SortSl() : () slip()
div1s():
procedure slip (var sq1,sqk,sr1,srk,sp1,spk:TSel);
var infq,infr:Tinf;
begin
sp1:=nil; spk:=nil;
while (sq1<>nil) and (sr1<>nil) do
begin
DelBeg(sq1,sqk,infq);
DelBeg(sr1,srk,infr);
if infq<infr then begin
AddEnd(sp1,spk,infq);
AddBeg(sr1,srk,infr);
end
else begin
AddEnd(sp1,spk,infr);
AddBeg(sq1,sqk,infq);
end;
end;
while sq1<>nil do
begin
DelBeg(sq1,sqk,infq);
AddEnd(sp1,spk,infq);
end;
while sr1<>nil do
begin
DelBeg(sr1,srk,infr);
AddEnd(sp1,spk,infr);
end;
end;
procedure div1s(var sp1,spk,sq1,sqk,sr1,srk:TSel);
var inf:Tinf;
begin
sr1:=nil; srk:=nil;
sq1:=nil; sqk:=nil;
while sp1<>nil do
begin
DelBeg(sp1,spk,inf);
AddEnd(sq1,sqk,inf);
109

if sp1<>nil then begin


DelBeg(sp1,spk,inf);
AddEnd(sr1,srk,inf);
end;
end;
end;
procedure SortSl(var w1,wk:TSel);
var sq1,sr1,sqk,srk:TSel;
begin
if w1<>wk then
begin
div1s(w1,wk,sq1,sqk,sr1,srk);
sortsl(sq1,sqk);
sortsl(sr1,srk);
slip(sq1,sqk,sr1,srk,w1,wk);
end;
end;
17.5.
,
, , .

110

. 17.4.
unit Unit1;

17.1

interface
uses Windows,Messages,SysUtils,Variants,Classes,
Graphics,Controls,Forms,Dialogs,StdCtrls,ExtCtrls,
Buttons;
type
TForm1 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
ListBox3: TListBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
111

Edit1: TEdit;
Label4: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var Form1: TForm1;
implementation
uses List1S;
var w1,w2,w3:TSel;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
bitbtn2.enabled:=false; //
bitbtn3.enabled:=false; //
bitbtn5.Enabled:=false; //
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var k,n : integer; //
begin
n:=strtoint(edit1.Text);
ListBox1.Clear;
ListBox2.Clear;
ListBox3.Clear;
w1:=nil; Randomize;
for k:=1 to n do AddStek(w1,Random(100));
WrtStek(w1,ListBox1);
bitbtn2.enabled:=true; //
bitbtn3.enabled:=true; //
bitbtn5.Enabled:=true; //
end;

112

procedure TForm1.BitBtn2Click(Sender: TObject);


var t:TSel; //
k:integer;
begin
ListBox2.Clear; ListBox3.Clear;
t:=w1; w2:=nil; w3:=nil;
while t<>nil do
begin
k:=t^.inf; // .
if odd(k) then AddStek(w2,k)
else AddStek(w3,k);
t:=t^.a; //
end;
WrtStek(w2,ListBox2);
WrtStek(w3,ListBox3);
bitbtn2.enabled:=false; //
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
//
case RadioGroup2.ItemIndex of
0: begin
case RadioGroup1.ItemIndex of
0: SortAfter(w1);
1: Sortinf(w1);
end;
WrtStek(w1,ListBox1);
end;
1: begin
case RadioGroup1.ItemIndex of
0: SortAfter(w2);
1: Sortinf(w2);
end;
WrtStek(w2,ListBox2);
end;
2: begin
case RadioGroup1.ItemIndex of
0: SortAfter(w3);
1: Sortinf(w3);
end;
WrtStek(w3,ListBox3);
end;
end;
bitbtn3.enabled:=false;
113

end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
bitbtn3.enabled:=true;
end;
procedure TForm1.RadioGroup2Click(Sender: TObject);
begin
bitbtn3.Enabled:=true;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
//
listbox1.Clear;
listbox2.Clear;
listbox3.Clear;
DelStek(w1);//
DelStek(w2);//
DelStek(w3);//
bitbtn2.Enabled:=false;
bitbtn3.Enabled:=false;
bitbtn5.Enabled:=false;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
// lose
DelStek(w1);
//
DelStek(w2);
//
DelStek(w3);
//
end;
end.
17.6.
, , , . , :
Type Tinf=integer; //
Tseld=^seld; // 2-
seld=record
inf:Tinf;
a,b:Tseld;
end;
114

,
. 17.5 17.7 .

sp1

sp2

sp3

sp k-1

sp k

a1

a2

a3

ak-1

ak

inf1

inf2

inf3

infk-1

infk

b1

b2

b3

bk-1

bk

. 17.5.

sp1

sp2

sp3

sp k-1

sp k

a1

a2

a3

ak-1

ak

inf1

inf2

inf3

infk-1

infk

b1

b2

b3

bk-1

bk

. 17.6.

115

spn

spn+1
an

an+1

infn

infn+1

bn

bn+1
a
inf
b

. 17.7.
17.7.
, ,
List2S, .

Procedure AddBegD(var w1,wk:Tseld; inf:Tinf);
var t:Tseld;
begin
New(t);
t^.inf:=inf;
t^.b:=nil;
if w1=nil then begin t^.a:=nil; w1:=t; wk:=t; end
else begin t^.a:=w1; w1^.b:=t; w1:=t; end;
end;

Procedure AddEndD(var w1,wk:Tseld; inf:Tinf);
var t:Tseld;
begin
New(t);
116

t^.inf:=inf;
t^.a:=nil;
if wk=nil then begin t^.b:=nil; w1:=t; wk:=t; end
else begin t^.b:=wk; wk^.a:=t; wk:=t; end;
end;
sp
Procedure AddAfterD(sp:Tseld; inf:Tinf);
var t:Tseld;
begin
//
if (sp=nil) or (sp^.a=nil) then exit;
New(t);
t^.inf:=inf;
t^.a:=sp^.a;
t^.b:=sp;
sp^.a:=t;
t^.a^.b:=t;
end;
sp
Procedure AddBefD(sp:Tseld; inf:Tinf);
var t:Tseld;
begin //
if (sp=nil) or (sp^.b=nil) then exit;
New(t);
t^.inf:=inf;
t^.a:=sp;
t^.b:=sp^.b;
sp^.b^.a:=t;
sp^.b:=t;
end;

Procedure DelBegD(var w1,wk:Tseld; var inf:Tinf);
var t:Tseld;
begin
if w1=nil then exit;
inf:=w1^.inf;
t:=w1;
if w1=wk then begin w1:=nil; wk:=nil; end
else begin w1^.a^.b:=nil; w1:=w1^.a; end;
Dispose(t);
end;
117


Procedure DelEndD(var w1,wk:Tseld; var inf:Tinf);
var t:Tseld;
begin
if wk=nil then exit;
inf:=wk^.inf;
t:=wk;
if w1=wk then begin w1:=nil; wk:=nil; end
else begin wk^.b^.a:=nil; wk:=wk^.b; end;
Dispose(t);
end;
c sp
Procedure DelD(sp:Tseld; var inf:Tinf);
begin //
if (sp=nil) or (sp^.a=nil) or (sp^.b=nil) then exit;
inf:=sp^.inf;
sp^.b^.a:=sp^.a;
sp^.a^.b:=sp^.b;
Dispose(sp);
end;

Procedure DelSpisD(var w1,wk:Tseld);
var inf:Tinf;
begin
while w1<>nil do DelBegD(w1,wk,inf);
end;
Memo
procedure WrtBegD(w1:Tseld; s:TMemo);
var t:Tseld;
begin
t:=w1; s.clear;
while t<>nil do
begin
s.lines.add(IntToStr(t^.inf));
t:=t^.a;
end;
end;
Memo
procedure WrtEndD(wk:Tseld; s:TMemo);
var t:Tseld;
118

begin
t:=wk; s.clear;
while t<>nil do
begin
s.lines.add(IntToStr(t^.inf));
t:=t^.b;
end;
end;
SortSlD() : () slipD() div2s():
procedure slipD (var sq1,sqk,sr1,srk,sp1,spk:TSeld);
var infq,infr:Tinf;
begin
sp1:=nil; spk:=nil;
while (sq1<>nil) and (sr1<>nil) do
begin
DelBegD(sq1,sqk,infq);
DelBegD(sr1,srk,infr);
if infq<infr then begin
AddEndD(sp1,spk,infq);
AddBegD(sr1,srk,infr);
end
else begin
AddEndD(sp1,spk,infr);
AddBegD(sq1,sqk,infq);
end;
end;
while sq1<>nil do
begin
DelBegD(sq1,sqk,infq);
AddEndD(sp1,spk,infq);
end;
while sr1<>nil do
begin
DelBegD(sr1,srk,infr);
AddEndD(sp1,spk,infr);
end;
end;
procedure div2s(var sp1,spk,sq1,sqk,sr1,srk:TSeld);
119

var inf:Tinf;
begin
sr1:=nil; srk:=nil;
sq1:=nil; sqk:=nil;
while sp1<>nil do
begin
DelBegD(sp1,spk,inf);
AddEndD(sq1,sqk,inf);
if sp1<>nil then begin
DelBegD(sp1,spk,inf);
AddEndD(sr1,srk,inf);
end;
end;
end;
procedure sortslD(var w1,wk:TSeld);
var sq1,sr1,sqk,srk:TSeld;
begin
if w1<>wk then
begin
div2s(w1,wk,sq1,sqk,sr1,srk);
sortslD(sq1,sqk);
sortslD(sr1,srk);
slipD(sq1,sqk,sr1,srk,w1,wk);
end;
end;

17.8.
.
1- .
. ..

120

. 17.8.
unit Unit1;

17.2

interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs, ExtCtrls, StdCtrls,Grids,
Buttons, List2S;
type TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
BitBtn1: TBitBtn;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button4: TButton;
Memo1: TMemo;
Memo2: TMemo;
Memo3: TMemo;
Memo4: TMemo;
Memo5: TMemo;
Button5: TButton;
Memo6: TMemo;
121

Label1: TLabel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
w11, w12, w13, wk1, wk2, wk3 : Tseld;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
memo2.Clear;
memo3.Clear;
memo4.Clear;
memo5.Clear;
memo6.Clear;
w11:=nil;
wk1:=nil;
w12:=nil;
wk2:=nil;
w13:=nil;
wk3:=nil;
Randomize;
button4.enabled:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// 1-
AddEndD(w11,wk1,Random(100));
WrtBegD(w11,memo1); // 1-
button3.Enabled:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin // 2-
AddEndD(w12,wk2,Random(100));
WrtBegD(w12,memo2); // 2-
end;

122

procedure TForm1.Button3Click(Sender: TObject);


var t,tmin,tmax:Tseld; //
i,min,max:integer;
inf:Tinf;
begin
t:=w11;
tmin:=t;
tmax:=t;
i:=1;
min:=1;
max:=1;
while t<>nil do
begin
if t^.inf<tmin^.inf then begin tmin:=t; min:=i; end;
if t^.inf>tmax^.inf then begin tmax:=t; max:=i; end;
t:=t^.a;
inc(i);
end;
if min=max then
begin
ShowMessage(' 1- ');
button3.Enabled:=false;
exit;
end;
if min>max then
begin t:=tmin; tmin:=tmax; tmax:=t; end;
if abs(max-min)>1 then
begin
t:=tmin^.a;
while t<>tmax do
begin// . min max 1-
DelD(t,inf);
AddEndD(w13,wk3,inf); // 3-
t:=tmin^.a;
end;
end;
WrtBegD(w11,memo3); // 1-
WrtBegD(w13,memo4); //
t:=tmin;
while w12<>nil do
begin
DelBegD(w12,wk2,inf);
// 2-
AddAfterD(t,inf); // min max 1-
t:=t^.a;
end;
WrtBegD(w11,memo5);
//
button4.enabled:=true;
end;
123

procedure TForm1.Button4Click(Sender: TObject);


begin
//
sortslD(w11,wk1);
WrtBegD(w11,memo6);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
//
memo1.Clear;
memo2.Clear;
memo3.Clear;
memo4.Clear;
memo5.Clear;
memo6.Clear;
DelSpisD(w11,wk1); //
DelSpisD(w12,wk2); //
DelSpisD(w13,wk3); //
end;
procedure TForm1.BitBtn1Click(Sender:
begin // Close
DelSpisD(w11,wk1); //
DelSpisD(w12,wk2); //
DelSpisD(w13,wk3); //
end;

TObject);

end.

124

18.

18.1.
: ,
, , . n , . .
.
n

aij x j

bi ; 1 i n,

Ax b ,

j 1

a11a12 ...a1n
A

a21a22 ...a2 n
...
an1an 2 ...ann

x1
, x

x2
...
xn

b1
, b

b2
...

(18.1)

bn

b , x *, (18.1). ,
det A 0 , . ( b 0 ), ( b 0 ). ,
det A 0 , , . .
b () aij x * . ,
, . (. 18.1).

125

. 18.1.
() . () A A 1 1.

1, 103 .
- . . .
(
) . n 200 .
,

.

x*
o
1
2
k
*
x , x , x , ..., x
x . ,
k

k
k

k 1

max xik
i

xik

. ( - ).

n>100,
.
, .
.
x :

126

max bk

1 k n

aki xi ;
i 1

, .
.
18.2.
18.2.1.
, , (18.1)

a11x1 a12 x2 ... a1n xn b1
a22 x2 ... a2 n xn

b2

.............................................

(18.2)

ann xn bn
.

(18.2), , , :
n
1
xn bn / ann ; xk
bk
aki xi , k n 1, n 2, ..., 1.
(18.3)
akk
i k 1
:
m- (m=2, 3,.., n) ,
am1 / a11, m- . 1- . , 2- , (m=3, 4,.., n) . . .
k- (k=1, 2 ,..., n-1), (18.2). . k- :
a
ami ami aki mk ,
k 1, n 1, i k , n;
akk
(18.4)
amk
bm bm bk
,
m k 1, n.
akk
akk . ,
akk 0 ,
. ,
k : k-

127

amk , k m n p , . . , k p. , . . (18.4) amk / akk


, , .
18.2.2.
(, 2-
) :
q1 r1 0 0 .. 0
0
0
x1
d1
p2 q2 r2 0 .. 0
0
0
x2
d2
0 p3 q3 r3 .. 0
0
0
x3
d3
(18.5)
.. .. .. .. .. ..
..
..
..
..
0 0 0 0 .. pn 1 qn 1 rn 1
xn 1
dn 1
0 0 0 0 .. 0
pn qn
xn
dn

q1x1
r1x2
d1,
pi xi
pn xn

qi xi

1
1

ri xi

qn xn

di ,

(18.6)

dn ,

2 i n 1.
.


(18.5)
x1
1
0 .. 0 .. 0
0
1
1
x2
0 1
0
2
2 .. 0 .. 0
(18.7)
..
..
.. ..
.. .. .. .. ..
..
0

.. 0 .. 1

n 1

xn

xn
0 0
0 .. 0 .. 0
1

,
r1 / q1 ;
d1 / q1;
1
1
i

ri /(qi

pi

i 1 );

(di

pi

i 1 ) /( qi

n 1
n

, -

i,

pi

i 1 );

(18.8)

i 2,3,..., n 1.
( ) ,

128

xn
xi

(d n

pn

i xi 1

n 1 ) /(qn
i

pn

n 1 );

(18.9)

i n 1, n 2, ..., 1.
(18.8), (18.9) . , ,
qi
pi ri ( i
).

18.2.3.
.

: A S T D S , D di= 1; S
( sik 0, i>k, sii 0 ), S T . S
A, . S D , A x S T D S x b
c
:
S T z b ; Dy z ; Sx y ,
(18.10)
z D S x, y S x . (18.10)
S , :
i 1

y1 b1 / s11d1;

yi

(bi

d k yk ski ) / sii di ; i

2, 3 ,..., n;

k 1
n

xn

yn / snn ; xi

( yi

sik xk ) / sii ; i

n 1, n 2, ..., 1.

k i 1

S ( )
:
2

k 1

dk

di sik ) ;

sign(akk
i 1
k 1

skk

akk

d i sik

i 1

(18.11)

1, 2,..., n;
k 1

skj

(akj

di sik sij ) /( skk d k );


i 1

1, k

2, ..., n.
129

k=1
d1 sign(a11 ); s11
a11
S ( s1 j , j 1) , k=2, s22 s1 j j>2
.. , . .
. sign(x)
1 x<0 +1 x>0.
18.3.
18.3.1.
(18.1) , x :
(18.13)
x Gx c
( x) ,
G ; c . (18.13)
(18.1).
xk
( x k 1 ) Gx k 1 c , k 1, 2, ...
x 0 (, x10 1, ..., xn0 1) , . ,
G 1 . (18.13) ( Ax b ) ( E
A) x
b Gx c , E , , x x
; - , , ,
E
A 1. , A
G
n

, . . aii

aik ,
k 1
k i

(18.1) (18.13) , i- xi . :

xik

bi

aij x kj 1

j 1
j i

gij

aij / aii ; gii

/ aii

gij x kj

ci .

(18.14)

j 1

0; ci

bi / aii .

18.3.2.
.
, xik (2 i n)

130

(18.14) x1k 1, ..., xik 11


x1k , ..., xik 1, . . (18.14)

xik

i 1

gij x kj

j 1

gij x kj

ci

(18.17)

j i 1


. ,
, xik .
, x0j xj x0i=1, x0i=xi.
18.3.3.
,
G . G
1, . . , xik
(18.19)
xik
xik (1
) xik 1,
0 <
2 . < 1 ,
>1- .
,
.
18.4.
A
A, E
AA-1=A-1A=E
A (
), . detA-1=1/detA. n- X.
-1

X=A-1=

x11

x12

... x1n

x21
...

x22
...

... x2 n
... ...

xn1

xn 2 ... xnn

AX=E, X
.
n2 n2 ,
131

.
n n .
A, . AX=E
n
a ijx jk {1,0, ii k,
k,
j 1
i=1,2,...,n ;
k=1,2,...,n
. . k-
k- ,
k- . , n- n
n- .
A,
(
)
. n ,
n .

132

19.

A ,

Ax= x,
x=[x1, x2, , xn]T - ,
(19.1)
(A- E)x=0, E .
D=A- E =

a11
a21
...
an1

a12
a22
...
an 2

...
...

a1n
a2 n

...
...
... ann

A. A
det D=0,
(19.2)
n- . x={x1, x2,
... ,xn}, (19.1) A.
19.1.
n+1 0, 1, ..., n. i f( )=det D=det (A- E). i, f( i) Pn( ), . n
Pn( )=0, .
.
, .
c .
1. .
2. ,

. , .
3. A B , . .
B=P-1AP
(19.3)
133

. (19.3) ,
. , A
. ,
(b11 - ) (b22 - ) ... (bnn - )=0. ,
. .
19.2.

A (A=AT)
. A D D=T1
AT, T-1 , A
T (T-1=TT),
D=TTAT, TT . D A,
T .
T
T=T1T2T3 ... . :
s- A(s) (A(0)=A) akm(s) A(s)
(akm(s)=max|aij(s)|, i<j). T(s), A(s+1)=T(s)TA(s)T(s) akm(s+1) A(s+1).
T(s)
tkm(s)=sin(s), tmk(s)=sin(s), tkk(s)=cos(s), tmm(s)=cos(s), (s) akm(s+1)=0:
(s)=1/2*arctg(2akm(s)/(akk(s)amm(s))), akk(s)amm(s),
(s)=/4, akk(s)=amm(s).
A(s+1)=T(s)TA(s)T(s).
, A
: |aij| < , i < j. ,
a2kk(s+1)+a2mm(s+1)=a2kk(s)+a2mm(s)+2akm(s), . .
. , . , ,
.

134

19.3.
, . ,
, . , .
(19.1)
(k) (k)
x = Ax( k 1 ),
k=1, 2, ...
(19.4)
, ,
x(0) x(1),
x(2), x(3),.... k x(k)
, .
(k) ,
x(k) .
|( (k) - (k-1))/ (k)| < ,
.

. x(0)
, . ,
,
(19.1) A-1 x/ =A-1 x.
x(k)/ (k) =A-1 x(k 1), (19.4) , 1/ , ( A A-1 ).

135

20.
20.1.

.
y=f(x). (x) - f(x),
, , . (x) ,
. , (x) c1, c2, , cn, . . (x)=(x, c1, c2, , cn), ,
f(x) (x). ( x, ) .
, ,
. ,
, ( x, ) , , . . :
n

( x, ) 1 1 ( x) ... n

n ( x)

k ( x) ,

(20.1)

k 1

{ 1 ( x), ..., n ( x)} ()


. {k(x)} : , , . , , . . f(x) (20.1) n
.
. {k(x)=xk-1}.
{k(x)}
[-1, 1] :
1; 2 x x; k 1 x
2k 1 x k x k k 1 x , k 2,3, ..., n ;
1 x
1
k

x dx 0; k

l.

136

, f ( x) [a, b],
b a 2
x
, a x b
x
2 b a
1 x 1. [a, b]
x a
x a
cos(2k
),
sin(2k
) .
k x
k x
b a
b a
(20.1) : y

ck

k ( x)

dk

k ( x) .

k 1

20.2.
.
. x, [a, b], f(x) (x) ,
() x1 x2 ... xn , (
x ( x1, ..., xn ) ),
1, 2 , ... , n . , , ( x, )
f(x) , . . (xi)=f(xi), i=1, 2, , n (. .
20.1), n , , . (20.1) :
n

k ( xi )

fi ; i 1, 2, ..., n; fi

f ( xi ),

(20.2)

k 1

{k(x)}, ,
, . . , (20.2)
, , . ,
.

137

. 20.1.

n-1, n .

( x, )

Pn 1 ( x) 1 2 x 3 x

... n x

n 1

ak x k 1 .

(20.3)

k 1

(20.2)
1 x1 .. x1n 1
G

1 x2 .. x2n
..

..

..

..

xk

(20.4)

xm

n k m 0

1 xn .. xnn 1
, xi .
(20.2) , . . .
f(x) n-1,
n , , n,
f ( x) Pn 1 ( x)

2
(n 1)

d n f ( x)
dx n

(h / 2) n , h max | xi

xi 1 | .

(20.5)

(20.5) , h 0 p p=n. n, h.
, ,
(n 6), , n
- .

138

20.3.
-,
1 2 x x 2 ( x 1) 2 .

. (20.3)
. , ,

( xi , yi ), i 1 ... n
20.3.1.
(20.1), (20.2)
.
(20.2) (1, 2 , ..., n ) .
(20.3) ,

n 1

N n 1 ( xT )

f1

( xT

x1 )( xT

x2 )...( xT

xk )

(20.6)

k,

k 1

xT , , k
k, :
fi fi 1
i f ( xi xi 1 )
1 f ( xi 1xi 2 )
;
; ...
1 f ( xi xi 1 )
2 f ( xi xi 1xi 2 )
xi xi 1
xi xi 2
20.3.2.
m>3 (n=3) (n=2) .
f(x) x
(i-1), i, (i+1)-
,

f fi 1
(20.7)
N1 ( xT ) fi 1 ( xT xi 1 ) i
; xi 1 xT xi ;
xi xi 1

N 2 ( xT )

N1 ( xT ) ( xT

xi 1 )( xT

xi )

fi
xi

1
1

fi
xi
xi

fi
xi
1

xi

fi
xi

1
1

; xi

xT

xi

1,

139

f(x) N1 ( x) ( ) N 2 ( x)
( ).
20.3.3.
(20.3)
, :
n
n
xT xi
Ln 1 ( xT )
fk
.
(20.8)
x
x
k 1
i
i 1 k
i k
n

i 1
i k

xT
xk

xi
, , k-, xi

, k- :
n
xT xi 1, xT xk
i 1
i k

xk

xi

0, xT

xk

(20.8) , Ln 1 ( xi )

fi

20.3.4.
, (20.3),
. ,
,
, ( )
(20.3). (20.2)
c (20.4), ( )
Pn 1 x c1 x(c2 ... x(cn 2 x(cn 1 xcn ) ...) .
(20.9)
20.4.
, x, c ,

x, c , . .
f(x)

min f ( x)

c1 ,...,cn

x, c

L2

(20.12)

(20.1) (20.12)
:

140

n
i

k L2

k 1

i k L2

f,

ck

f,

i L2

i L2

(20.13)

; i 1,..., n,

L2.

(20.13) , . ,
k x , . . ,
0,
i

2
k

, i

k
k.

(20.13) c
f, k
. (20.1) ck
2
k

, ck .
20.4.1.
.
x, [a, b], f(x) (x) , () x1, ..., xm, ,
c1, ..., cn , m n. , ,
(. . 20.2)
m

min
c

[ f (x j )
j 1

( x j , c )] 2

min
c

2
j

min (c ),

j 1

(20.13)

c1, ..., cn .

. 20.2.

141


. (20.1),
c ( ):
(c1, c2 ,..., cn )
(20.14)
0, i 1,2,..., n,
ci
n n
c1, ..., cn :
n

k )ck

(f,

i ),

i 1,..., n

b,

(20.15)

k 1

i ( x1 ),

i ( x2 ),

... ,

i ( xm )

, f

f1, ... , f m - -

. G b (20.15)
m

gik

k)

i ( x j ) k ( x j ),
j 1

bi

(f,

i)

fj

i (x j )

j 1

(20.15) G .
i ,
.

142

21.
21.1.
d m f / dx m x . x x1, x2 , ..., xn (n
m+1), ( x ). fi f ( xi ) , d m Pn 1 / dx m
( ) n
m
m
: d m f / dx m
m [ f ] d Pn 1 / dx . n=m+1 x . m m- Pm(x) ,
.
max f ( m) ( x)
dm f
n
x
(21.1)
max
max x xi Chn m .
m[ f ]
m
x1 x xn dx
i
(n m)
h max xi xi 1 ; C const , n m 1
, x
. , ,
x. , h 0
n-m 1, n,
h ( ). , (20.7) .
df dP1
f 2 f1
2
(21.2)
; x1 x x2 .
1 [ f ( x)]
dx dx
h
(21.2) .
df dP2
f 2 f1
f 2 f 2 f3
3
(21.3)
(2 x x1 x2 ) 1
1 [ f ( x)]
dx dx
h
2h 2
x1 x x3
,
. ,
(21.3)
df ( x2 )
f3 f1
3
(21.4)
;
1 [ f ( x2 )]
dx
2h

143

df ( x1 )
3 f1 4 f 2 f3
3
(21.5)
;
1 [ f ( x1 )]
dx
2h
df ( x3 )
f1 4 f 2 3 f3
3
(21.6)
;
1 [ f ( x3 )]
dx
2h

d 2 f d 2 P2
f1 2 f 2 f3
(21.7)
;
x1 x x3 ,
2 [ f ( x)]
2
2
dx
dx
h2
x2.

21.2.
b

f ( x)dx a

. [a, b] m
h b a / m . b

xi

f ( x) dx , xi

f x dx
i 1 xi

a ih.

xi 1, xi 1 5 .
.
( )
. .
21.2.1.
, i- [xi-1, xi]
xi-1/2 = xi - h/2, .

() P0(x) = f(xi-1/2). :
m xi

f ( x)dx

P0 ( x)dx h
i 1 xi

fi

1/ 2

f.

(21.8)

i 1

h:
b

max

f ( x)dx
a

h2
f ( x)dx .
24 a

(21.9)

144

21.2.2.
f(x) xi 1, xi , . .
, ( xi 1, fi 1 ) , ( xi , fi ) .
fi 1 , fi h
b

xi

f ( x)dx

P1 ( x)dx
i 1 xi

fi

i 1

fi

f0

fm
2

m 1

fi

f.

(21.10)

i 1

, :
b
m

max

f ( x)dx

h2
f ( x)dx .
12 a

(21.11)

21.2.3.
f(x) xi 1, xi () c xi 1, xi 1/ 2 , xi .
b

xi

f ( x)dx

P2 ( x)dx
i 1 xi

h m
( fi
6i 1

4 fi

1/ 2

fi )

(21.12)

(21.12)
:
m
m 1
h
f0 f m
f
2
f
fi
i 1/ 2
cu
3
2
i 1
i 1
h:
b

max

f ( x)dx
a

cu

h4
f (4) ( x)dx .
2880 a

(21.13)

21.2.4.
() .
,
( ), . .
.
n n xi 1, xi ,
. , , ,
o n- . , n=1
145

. , . n=2 xi 1, xi
:
h
xi1,2 xi 1/ 2
0.5773502692
2

b
hm
f ( x)dx
[ f ( xi1 ) f ( xi2 )] .
(21.15)
2
i 1
a
h 0 , . . ,
, ! n=3 xi 1, xi :
h
xi0 xi 1/ 2 ,
xi1,2 xi0
0.7745966692
2

b
h m
(21.16)
f ( x)dx
5 f ( xi1 ) 8 f ( xi0 ) 5 f ( xi2 ) .
18
i
1
a
h 0 , . .
, ,
. , , , .

146

22.

22.1.

y=f(x). f(x) .
x, f(x) , . . f(x)=0.
(22.1)
,
.
(22.1) :
1. , .
2. .
. 22.1 :

. 22.1.
) : f ( x1* ) 0, f ( 1 ) f ( 1 ) 0;
) : f ( x2* ) 0, f (

2)

f(

2)

0;

) : f ( x3* ) , f ( 3 ) f ( 3 ) 0 .
. 22.1, a) )
.

. , m-
, [a, b],
x, m x0, x1, , xm-1 ( x0=, xm1=b), (xm, xm+1, ..., xn-1, xn) 147

( xk 1, ..., xk m )
m xk
, xn xn 1
. xn
(x* xn), .
(x). .

22.2.
22.2.1.
, (22.1) , x: x
( x) (22.2)
, (22.1)
(22.2) , ,
(x)=x+(x)f(x),
(22.3)
(x) , , ( (x)=const). (22.2)
(22.1), . (22.2)
xk
( xk 1 ), k 1,2,... .
(22.4)
, x0=a x0=b x0=(a+b)/2. , ( x) , |'()| < 1 [a, b], x* [a, b].
(22.5)
[a, b], (22.5),
. (22.5)
, x0 .
x* xk

k
, k
k 1q
*
q |'(x )|, . . q, , . (22.1) (22.2) (x) (22.3) , (22.5)
[a, b] q. .
.
22.2.2.

. f(x) ,
, (22.3) (x)= -1/f'(x), x=x
f(x)/f'(x)=(x), q |'(x*)|0.
148

f ( xk 1 )
(22.6)
( xk 1 )
f ( xk 1 )
, k
( x*) k2 1 . (22.6)
, (m=1) x0 , | f(x)f''(x) |<[f'(x)]2.
, . 22.2.
, . f'(x).
xk

xk

. 22.2.
22.2.3.
,
(21.2). , .
22.2 . (22.6)
f ( xk 1 ) h
(22.7)
xk xk 1
( xk 1 ),
f ( xk 1 ) f ( xk 1 h)
h ,
. (m=1),
h , .

149

22.2.4.
.
xk 1 h (22.7) xk 2 , . :
f ( xk 1 )( xk 1 xk 2 )
(22.8)
xk
xk 1
( xk 1 , xk 2 ).
f ( xk 1 ) f ( xk 2 )
(m=2), x0 , x1 . x0=a, x1=b. , , f(x) .
22.2.5.
(, , )
, f(x)
. , ,
. . : x0 , x1, x2 , ( f ( x0 ) f ( x2 ) 0, x1 ( x0 x2 ) / 2 ) ,
f ( x) : f 0 , f1, f 2 ,
P2 ( x) a( x x2 )2 b( x x2 ) c az 2 bz c .
(22.9)
:
z=x-x2;

z1=x1-x2;

f 2 ) / z0 ( f1 f 2 ) / z1
;
z0 z1
(22.9) :
a

( f0

z0=x0-x2;

c=f2;

b ( f0

f 2 ) / z0

a z0 .

(22.10)

z1, 2 ( b
b 2 4ac ) /(2a),
zm ,
xm x2 zm . xm x1
xm,
xm: xm < x1 x2=x1, f2=f1, x1=xm, f1=f(xm), x0=x1, f0=f1,
x1=xm, f1=f(xm) .

22.2.6.
, f(x)
. 150

. , . ,
[a, b] .
:
, x0=a, x1=b, x ( x0 x1 ) / 2, , . x , , .
.
1. f 0 f ( x0 ), f1 f ( x1 ) .
2. x x0 x1 / 2, f m f ( x ) .
3. f 0 f m 0, x0 x, f 0 f m , x1
, . 2.
4. x1 x0
5. x* ( x0 x1 ) / 2.

x , f1

fm.

, ,
.

151

23.

23.1.
, . . , . , , , , .
, , .
, . , n- n 1- . ,

du1 ( x)
f1 ( x, u1 , ..., um )
dx
. . . . . . . . . . . . . .
dum ( x)
dx

(23.1)

f m ( x, u1 , ..., um )

u ( x) u1 ( x), ..., um ( x) x a x b . , (23.1)


,
m 1, ..., cm
u u ( x, c ) . , . .
, m u u1, ..., um .
, :
() , a
( x=a), b ( x=b).
;
( ),
u1 (a) u10 ; ...; um (a) um0 .
(23.2)
152


(23.1), (23.2) :
du
(23.3)
f ( x, u ); u (a) u 0 .
dx
u ( x) a x b.
23.2.
(23.3) .
.
a x0 x1 x2 ... xn b, . xi , hk xk xk 1 . hk h (b a) / n , . h max hk ;
k

, . u ( x)
u k u ( xk ) , , . - . - . - . - (23.3) xk 1, xk k=1,2,...,n
xk

xk

xk

du
dx u k
dx

k 1

f ( x, u ( x))dx
xk


xk

k 1

f ( x, u ( x))dx
xk

(23.4)

, - , .
,

, y k u k . - ,
y k 1
y k
y 0 , y1 , y 2 , ..., y n . , (23.2) -

y 0

u 0 ,

y k , k 1, ..., n.
-

153

. , p, h 0
(h) Ch p , C const. p,
:
(23.5)
(h) y u max y k u k
k

, , h 0 (h) ,
h
C0 h
C0 C h p ,
0 . ,
h y k
k, h, h/2, h/4 y k
,
. , ,
, h,
p, . . p , h. -
(23.4).
23.2.1. 1- ( )
(23.4)
yk

y 0

yk

h f ( xk 1, y k 1 ), k

1, 2, ..., n .

(23.6)

u 0 , (23.6)

y k , k 1, 2, ..., n , y k . (h) (h)


,
xk 1, xk , .

23.2.2. 1-
(23.4)
yk

yk

h f ( xk , y k ), k

1, 2, ..., n ..

(23.7)

y k , y k
(6.7):
y k , s y k 1 h f ( xk , y k , s 1 ); s 1, 2, ... , s .
154

y k , 0 y k 1
. , h , 2 3
y k , s y k , s 1
.
, 0
, .
23.2.3. 2-
(23.4)

h
(23.8)
f ( xk 1, y k 1 ) f ( xk , y k ) .
2
,
. (23.8)
y k , :
h
yk , s yk 1
f ( xk 1, y k 1 ) f ( xk , y k , s 1 ) , s 1, 2, ..., y k , 0 y k 1
2
yk

yk

23.2.4. 2-
(23.4)
y k y k 1 h f ( xk 1/ 2 , y k 1/ 2 ) .
(23.9)
y k , y k 1/ 2 [ xk 1, xk ] .
.
(23.6) y k 1/ 2 ():
h
y k 1/ 2 y k 1
f ( xk 1, y k 1 )
2
y k (23.9) (). . ,
, (s=1,
2).
23.2.5. 4-
(23.4)
h
(23.10)
yk yk 1
[ f ( xk 1, y k 1 ) 4 f ( xk 1/ 2 , y k 1/ 2 ) f ( xk , y k )] .
6
, ,
. -
155

y k (23.10), .
h
y k 1/ 2,1 y k 1
( f ( xk 1, y k 1 ),
2
h
y k 1/ 2, 2 y k 1
f ( xk 1/ 2 , y k 1/ 2,1 ),
2
k ,1
k 1
y
y
hf ( xk 1/ 2 , y k 1/ 2, 2 ),

h
yk yk 1
[ f ( xk 1, y k 1 ) 2 f ( xk 1/ 2, y k 1/ 2,1 )
6
2 f ( xk 1/ 2, y k 1/ 2, 2 ) f ( xk , y k , 1 )]
23.3.

(23.4)
[ xk 1, xk ] .
y k y k 1 .
. , , ,
xk 1 xk
f ( xk 1/ 2, y k 1/ 2 ) [ xk 1, xk ] . , ( 23.2.4, 23.2.5), . f ( x, y ) [ xk 1, xk ] . ,
y k 1, y k 2 , y k 3 , .... .
(23.4)
f ( xk 1 ) f ( xk 2 )
f ( x) f ( xk 1 ) ( x xk 1 )
h
(23.11)
f ( xk 1 ) 2 f ( xk 2 ) f ( xk 3 )
( x xk 1 )( x xk 2 )
... .
2h 2
[ xk 1, xk ] . ( , ).
[ xk 1, xk ] , xk 1, xk 2 , xk 3 .
156


(, xk 1, xk , ). (23.4) )

f ( xk ) f ( xk 1 )
f ( x) f ( xk ) ( x xk )
h
(23.12)
f ( xk ) 2 f ( xk 1 ) f ( xk 2 )
( x xk )( x xk 1 )
... ,
2h 2
.
, .
23.3.1. 2-
(23.4)
f ( xk 1 ) f ( xk 2 )
f ( x) f ( xk 1 ) ( x xk 1 )
,
h

h
(23.13)
yk yk 1
[3 f ( xk 1, y k 1 ) f ( xk 2 , y k 2 )]
2
, ,
, y1 2- , y 2 , y 3 , ...
(23.13).
23.3.2. 3-
(23.4)
f ( xk 1 ) f ( xk 2 )
f ( x) f ( xk 1 ) ( x xk 1 )
h
f ( xk 1 ) 2 f ( xk 2 ) f ( xk 3 )
( x xk 1 )( x xk 2 )
,
2h 2

h
[23 f ( xk 1, y k 1 ) 16 f ( xk 2 , y k 2 ) 5 f ( xk 3 , y k 3 ) (23.14)
12
, , , y1 , y 2 4- , y 3 , y 4 , ...
(23.14).
yk

yk

157

23.3.3. 3-
(23.4)
f ( xk ) f ( xk 1 )
f ( x) f ( xk ) ( x xk )
h
f ( xk ) 2 f ( xk 1 ) f ( xk 2 )
( x xk )( x xk 1 )
,
2h 2

h
(23.15)
yk yk 1
[5 f ( xk , y k ) 8 f ( xk 1, y k 1) f ( xk 2 , y k 2 )] .
12
, ,
, y1 4- , y 2 , y 3 , ...
(23.15). y k ,
y k
(23.15)

h
5 f ( xk , y k , s 1 ) 8 f ( xk 1, y k 1) f ( xk 2 , y k 2 )
12
k,0
y (23.13):
h
yk , 0 yk 1
3 f ( xk 1, y k 1 ) f ( xk 2 , y k 2 )
2
yk , s

yk

23.4. ()

y//+p(x) y/ + q(x) y = f(x)
(23.16)
[a, b]
/
1 y(a) + 1 y (a) = A
/
(23.17)
2 y(b) + 2 y (b) = B
, , .
.
-
{ 0(x), 1(x), , n(x)}, 0() (23.17), 1(x), 2(x), , n(x) .

158

y(x)

0 (x)

k 1

ck

k (x)

(23.18)

(23.18) (23.16) (23.16)

(x,c1 ,c2 ,...,cn )

(x) p(x) 0 (x) q(x) 0 (x) f (x)

ck [ k (x) p(x) k (x) q(x) k (x)]

(23.19)

k 1

1, 2, , n , (23.19) .
. n xk [a,b], k=1,2,,n, , .

1, 2, , n.
xk [a,b], k=1,2,,m; m>n. k , k=1, 2,
, n .

1(), 2(), , n() (23.19),
b

(x,c1 ,c2 ,...,c n )

k (x)dx

0, k 1, 2,..., n.

.
1, 2, , n . .
23.5.
23.5.1.

(23.16) (23.17) . y1(x)=dy/dx,
:
dy/dx = y1,
dy1/dx = f(x) p(x)y1 q(x)y
:
1y(a) + 1y1(a)=A,
2y(b) + 2y1(b)=B.
y(x):
y(a)=y0

(23.20)

(23.21)

(23.22a)
159

(23.21) y1(x):
y1(a)=(A- 1 y0)/ 1
(6.22)
(23.20) (23.22) , .
y(b), y1(b)
[a, b], , (23.21), F(y0)= 2 y(b)+ 2 y1(b)B=0. (23.16) (23.17) F(y0)=0 (23.20), (23.22).
,
.
23.5.2.
,
. , . (23.16) (23.17). [a,b] xk=a+kh, k=0, 1, 2, , n; h=(b a)/n.
(23.16) (23.17)
y(x) xk. yk = y(xk). , (23.16) :
y/(xk)=(yk +1yk 1)/(2h),
y//(xk)=(yk +12 yk+yk 1)/h2
(23.16) xk, k =1,2, ,n 1:
(yk+12yk+yk 1)/h2+pk(yk +1yk 1)/(2h)+qk yk=f k
(23.23)
k=1,2, ..., n1,
pk=p(xk), qk=q(xk), fk=f(xk). y/(a), y/(b) - . , , 0
n :
1y0+ 1(y1y0)/h=A
2yn+ 2(ynyn-1)/h=B

:
y/(x0)=(-3y0+4y1y2)/(2h)
y/(xn) =(3yn-4yn-1+yn-2)/(2h)
160

:
( 13 1/2h) y0+ 1(4y1y2)/(2h)=A
(23.24)
( 2+3 2/2h)yn+ 2(-4yn-1+yn-2)/(2h)=B
(23.23), (23.24)
(n+1)- , ,
(23.16), (23.17) y(x) 0, 1, , n.

161

24.
24.1. ,
, . , , , . .
, ,
,
.
( ) ,
. () n- R n . R n , . . X R n , (
) f ( x) n
x1 , x2 ,..., xn . f ( x) , ,
x
:
(0)

f (x )

(0)

min f ( x)
x

(24.1)

(0)

( , -

(0)

) , f ( x ) ( ).
(0)

: . , x
X
f ( x) ,
(0)

U ( x )

(0)

(0)

0) x , f ( x )

f ( x) -

(0)

U ( x ). f ( x)

(0)

x
X , x X . X R n , .
(0)

(0)

x , f ( x ) f ( x) R n . 162

.
. X R n , .
, .

(24.2)
X
x R n | g j ( x) 0, j 1, 2,..., k ; g j ( x) 0, j k 1,..., m
g j ( x) Rn , . (24.2) m = k;
(24.2) (k = 0),
, . ,
g ( x) 0 g ( x) 0, g ( x) 0. ,
g ( x) 0
- -,

xn 1
g ( x) 0

g ( x) xn2 1 0.

24.2.
min f(x) . ,
. , ,
.
. , , .
:
1. .
2. xmin c
.
, x0,
h 2h, , f(x-h)> f(x) <
f(x+h). , . 21.1, A < x0 < xg , [a,b] xmin1, xg < x0 < B xmin2, . . , x0. [a,b] f(x) , . .
xmin
, ,
163

. 24.1.
24.2.1.
.
[a, b] .
x ( a b) / 2 .
1. [a, b]:
2. , :
f ( x ) f ( x ), a x, b x.
3. |b-a| > , . 1.
4. xmin (a b) / 2, f min f ( xmin ).
, , .
24.2.2.
[a, b] .

(b x1 ) /(b a) ( x1 a) /(b x1 ) 1
0.618,
(3
5) / 2 0.382.
, , , . , .
, x1 x2 , ,

164

x1 a
(b a), x2 b
(b a ), f1 f ( x1 ), f 2 f ( x2 ).
, , , , ( x1 . 24.2)
.
, , .

. 24.2.
.
a, b .
1.
x1=a+(b-a), x2=b-(b-a), f1=f(x1), f2=f(x2).
2. f1>f2, a=x1, x1=x2, f1=f2, x2=b-(b-a), f2=f(x2),
b=x2, x2=x1, f2=f1, x1=a+(b-a), f1=f(x1).
3. |b-a|> , . 2.
4. xmin=(a+b)/2, fmin=f(xmin).
, xmin, , .
24.2.3.

n ( ; n-1).
xmin n-1 , . , :
165

x10=a0+Fn(b0a0)/Fn + 2,
x20=b0-Fn (b0 -a0)/Fn + 2=a0+Fn+1(b0a0)/Fn + 2,
Fn , Fn+1, Fn+2 ,
F1=F2=1, Fk =Fk-1+Fk2 ,
k=3, 4, ...
:
F1=1, F2=1, F3=2, F4=3, F5=5, F6=8, F7=13, F8=21, F9=34, F10=55.
, ,
x1k=ak+Fn-k(b0a0)/Fn+2,
x2k=ak+Fn-k+1(b0a0)/Fn+2.
n-1 , k = 1, 2, ..., n 1. ,
xmin =x1n -1. (b0
a0)/(2Fn+2), . . (n=2)
, 1/6 , (n=4) 1/16, (n=8) 1/110.

lim Fn / Fn

(3

5) / 2,

n
.
.
1. a, b n.
2. d=( b-a )/Fn+2 :
x1=a+Fnd, x2=b-Fnd, f1=f(x1), f2=f(x2).
3. f1 > f2 , a=x1, x1=x2, f1=f2, x2 = a+ Fn k+1 d, f2 = f (x2),
b=x2, x2= x1, f2= f1, x1 = a+ Fn k d, f1 = f (x1).
4. 2 3 n-1 , k=1, 2, ..., n-1.
5. xmin x1, f min f ( xmin ) .
24.2.4.

. , , x0 h , 2h, , , , , ( ).
.
x0 , h, (h>0) .
1. f 0 f ( x0 )
166

2. .
) f 0 , h
f ( x0
h.
3. x0 x1 x0 h f1 f ( x1 ) .
4. f1 f 0 , x0 x1, f 0 f1, . 3.
5. x1 , x0 , ,
.
, h= - h/4 h= - h/10.
6. h
, . 3.
7. xmin=x0, fmin=f0.
x0 h. h x0 xmin.
24.2.5.
3
x1, x2, x3 f(x2)<f(x1) f(x2)<f(x3).
, . C .
x1, x2, x3
f1, f2, f3.

p( x x3 )2 q( x
z x x3, z1
( f1 f3 )/ z1
p
z1

x3) r pz 2 qz r,
x1 x3, z2 x2 x3, r f3,
( f 2 f3 )/ z2
, q ( f1 f3 ) / z1 pz1.
z2

(24.3)

zm= - q/(2p). , xm=x3+zm , , ,


, . xm1, xm2, xm3, , xmin.
.
1. x1, x2, x3 .
2. f1=f(x1), f2=f(x2), f3=f(x3).
3. z1, z2, p, q, zm (24.3).
4. xm=x3+zm, fm=f(xm).
5. |xm - x2|<, xmin=xm, ,
: xm<x2 x3=x2, f3=f2, x2=xm, f2=fm,
x1=x2, f1=f2, x2=xm, f2=fm
. 3.
. , , , 167

p q -
. , . , , , , .
24.2.6.
, ,
.
x1 x2 ( f ( x1 ) 0, f ( x2 ) 0), f1, f2 D1 f ( x1 ), D2 f ( x2 ) .
, ,
x1 x2:

p( x x2 )3 q( x x2 )2 r ( x x2 ) s pz3 qz 2 rz s P( z),
z x x2 , z1 x1 x2 ,
P( z1) f1, P ( z1) D1, P(0) f 2 , P (0) D2.
, :
s f 2 , r D2 ,

p ( D1 D2 2( f1 f 2 ) / z1) / z12 ,
q (( D1 D2 ) / z1 3 pz1) / 2.

zm ( q

q 2 3 pr )/(3 p).


xm x2 zm , , ,
xm .
.
1. x1, x2, ( f'(x1) < 0, f'(x2) > 0 ) .
2. f1=f(x1), f2=f(x2), d1= f'(x1), d2= f'(x2), xp=(x1+x2)/2.
3. z1, p, q, r, zm, xm .
4. | xm-xp |< , xmin = xm.
xm:
f'(xm) < 0, x1=xm, f1=f(xm), d1= f'(xm),
x2=xm, f2=f(xm), d2= f'(xm),
xp = xm . 3.
168

24.3.

24.3.1.
n
0

x , x , x ,..., x ,...
f ( x) :
0

f (x )

f (x )

f ( x ) ...

f ( x ) ...

. .
k

k- x . p
k
min

R n ,

> 0
( 24.3).
k 1

k
k
x
x
min p .
: ,
k

k 1

x x 1
.

, p .

. 24.3.

k

k p . , k - k 0 , (k+1)-
169

k- , k

k 1
k
k

p
min / 2 .
,
. , ,
. , . . , . , ,
, . , , , .
,
,
. , , , .

24.4.
24.4.1.
. x0={x10, x20, ..., xn0} n . , x1 . x1={x11, x20, ..., xn0},
f(x) x1 . ,
x2 . .
n
||xnx 0|| < | f(xn)f(x0)| < ,
, . n . . ,
||xnk+1x0k|| <
|f(xnk+1)f(x0k)| < .

170

24.4.2.
, : , .
1. x0 = (x10, x20, ..., xn0),
d = (d1, d2, ..., dn)
.
2. f0=f(x0).
3. x1=x0, f1=f0.
4. m=0.
5. k- : xt=x1+dk k,
ft=f(xt), k xk. ft < f1,
x1=xt, f1=ft, ,
xt=x1-dk k, ft=f(xt). ft < f1, x1=xt,
f1=ft, , m .
(k=1,2,,n), .
6. m=n, . . , d (,
, ) 4- .
,
.
. d (dk < , k=1,2,,n), ,
x0 f(x) .
7. ,
.
x1 p=x1x0, .
f(x1+ p) . min x0=x1+ minp
2- .
24.4.3.
, . , n+1
n- , ,
. , 171

, . , .
n+1 .
,
. , ,
.
:
fi - i- , . . i = (xi);
m - , (), . .
m = max { i }, i=1,2,...,n+1
s , , . . s = max { i }, i=1,2,...,n+1; i m
l- (), . .
l = min { i }, i=1,2,...,n+1
x0 - , ,
x m:

1
n

n 1

xi

i 1
i m

.
. xm ,
,
xm xr , xr xm . r
m
r
m, , x x .
. 24.4 .
xr = x0+ (x0 - xm), > 0 .
xr xm x0 x0.
xr xl, xs, xm.
, :
l< r
s ;
;
r< l
s < r < m ;
;
r> m
xr xm
xs, xm xr ,
.

172

. 24.4.
. xr , r< l
, .. , , , x0 xr.
xe = x0 +
(xr - x0), >1 . e = (xe). e <
m
e
r , x x , , ( e > r ) xm xr, .
. xr, ,
s < r < m, .
, x0 xr, , .
xc = x0 + ( xr x0 ), - (0< <1).

m
= ( ). < r, x x x
xr. .
. ,
( r > m). , , , .
l
xi =(xi + xl)/2, i=1,2,...,n+1, . , n+1 , . .
fi
i

1/ 2

n 1

/ n

1
1 n

n 1

fi
i 1

, =1, =0,5, =2,


.

173

24.5.
, g

f (x)

df df
df
,
,...,
dx1 dx 2
dx n

. ,
g
.
.
, .

.
.
24.5.1.
-
(k+ pk)
pk=- (xk). :
xk+1=k+ minpk.
, :
||xk+1 xk|| <
||pk+1|| < .
24.5.2.
,
. :
xk+1=k+ k minpk, pk=- (xk)+ kpk-1,
k=1,2,; p0=- (x0)
, , - , , k .
k . , k=0
. ,
, k , i
(i n) . . v u
,
vTAu=0. ,
. k 174

p0, p1,, pn-1, . :


T

g (x ) g(x )
k

1.
2.
3.
4.
5.
6.
7.

df
d x ik

df
d x ik

1
g T (x k 1) g (x k 1 ) i 1
i 1
.
0 .
g0= (x0).
p0= -g0.
f(0+ p0)
.
1=0+ minp0. =1,2,, n -1 . 6 10.
gk= f(xk).
k
k

g Tk g k
g Tk 1 g k 1

8. pk=-gk+ kpk-1
9. (k+ pk)
.
10. k+1=k+ k minpk
11. ||xnx0|| < ||gn|| < .
12. , . 2, x0 xn.
24.6.
24.6.1.

. , - (k+ pk)
pk= -Hk-1gk, k-1 , ( ) k, gk
.
, . , ,
. ,
175

. k ,

. ,
,
, .
,
. k k=-kgk, k
, k-1. ,
,
().
24.7.
24.7.1.

( ) .
, . , .
-1.
0 .
:
T
k
vk vTk A k u k u k Ak
A k 1 Ak
vTk u k
u Tk A k u k
vk= kpk, uk=gk+1 gk.

1.
2.
3.

4.

.
0 .
0= ( ).
- (=0, 1, 2, ) :

df df
df
gk
f (x k )
,
,
...,
dx1k dx k2
dx kn
k=-kgk.

176

5. k
(k+ pk) .
6. n
vk= kpk.
7. xk+1=xk+vk.
8. k+1= ( + 1) gk+1= (xk+1)
xk+1.
9. , ||gk+1|| < ||vk|| < .
:
10. uk=gk+1gk.
11. k
k
vk vTk
A k u k u Tk A k
Ak 1 Ak
vTk u k
u Tk A k u k
12. . 3.
24.8.
24.8.1.
(24.1) :
X={x Rn | gj(x) 0 , j=1, 2, , k; hj(x)=0 , j=1, 2, , m }
{ : b(x) 0
g(x) 0 - b(x) 0 }, ( , ) ,
. (),
Rn , :
1. ()=0 .
2. () > 0 .
, ()
. , ,
:
()=

( max {g j ( x); 0} )

j 1

h j( x )

j 1

p :
k

(x)
j 1

2
j ( x ) g j ( x ) 1 sign g j ( x )

m
j ( x)

h 2j ( x),

j 1

j > 0, j > 0 ,
.
min f(x)
x X
177

:
min F(x),
F(x)=f(x)+r (x),
r > 0 .
x Rn
r, j, j
. F(x)
, . , .
r (, rk=k rk=10k, k=1,2,).

178

1.

( ).

Function StrToFloat(S:
S
String): Extended;
.

Function StrToInt(S: String): S .
Integer;

Procedure Val(S: String;


S
var X, Code: Integer);
X, . Code ,

Function FloatToStr( Value: Value
Extended): String;

Function FloatToStrF(Value: Value


Extended; Format: TFloat- Precision Digits
Format; Precision, Digits: In- (. )
teger) : 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
179

ffNumber
ffCurrency

ffFixed -
(
Windows )
. ffNumber,
(
Windows .). Value = *1000 : 3 141,60

180

2.
Object Pascal . Math.
.

Log a (x)

Ln( x)
Ln( a )

xa

ea

Ln (x )

Math
LogN(a, x)
Power(x,a)

Tg (x)

Sin( x)
Cos ( x)

Tan(x)

Ctg (x)

Cos ( x)
Sin( x)

CoTan(x)

ArcSin(x)

ArcTg

ArcCos (x)

ArcCtg (x)

Sh(x)
Ch(x)

Sign( x)

x
1 x2

ArcSin(x)

ArcSin(x)
ArcCos(x)

ArcTg (x)

ex

e
2

ex

e
2

Sinh(x)

1, x>0;
0, x=0;

-1, x<0

Cosh(x)
Sign( x)

181

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
138
139
140


144 160
145 161
146 162
147 163
148 164
149 165
150 166
151 167
152 168
153 169
154 170
155 171
156 172

176
177
178
179
180
181
182
183
184
185
186
187
188

192
193
194
195
196
197
198
199
200
201
202
203
204

208
209
210
211
212
213
214
215
216
217
218
219
220

224
225
226
227
228
229
230
231
232
233
234
235
236


240
241
242
243
244
245
246
247
248
249
250
251
252
182

141
142
143

157 173
158 174
159 175

189
190
191

205
206
207

221
222
223

237
238
239

253
254
255

" ", "".

183


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.

184