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

. .

Programming Taskbook

4.6

--
2007

PDF-: 25.01.2007.

c . . , 19982007


Programming Taskbook Pascal, Visual Basic, C++, C#, Visual Basic
.NET. 1000 , :
.
4.6 Programming Taskbook : Borland Delphi 3.07.0 2006, , Turbo Delphi 2006
for Windows, Microsoft Visual Basic 5.0 6.0, Borland C++Builder 4.0 5.0,
Microsoft Visual C++ 6.0, Microsoft Visual Studio .NET 2003 2005,
Visual Studio .NET 2005 Express Edition ( Visual C++, Visual Basic .NET
Visual C# .NET). , Pascal ABC ( . . . ),
Pascal ABC & Programming Taskbook.
Programming Taskbook
:
;
;
;
-;
, ;
;
.

,
-, ,
, . ,
, .
( ):
Begin , (40),

. . . Programming Taskbook 4.6

Integer (30),
Boolean (40),
If (30),
Case (20),
For (40),
While (30),
Series (40),
Proc (60),
Minmax (30),
Array (140),
Matrix (100),
String (70),
File (90),
Text (60),
Param (70),
Recur (30),
Dynamic (80).

PDF- Programming Taskbook


. ,
[13] [46].
, , - PT4Mini250. - 250 ,
Begin, Integer, Boolean, 140 . , -
,
, ,
C# VB .NET. , -
PT4Mini250:
Begin1Begin40, Integer1Integer30, Boolean1Boolean40, If4, If6, If8, If12,
If22, If26, Case2, Case4, Case9Case10, Case18, For5, For12For13, For15For16,
For19For20, For33, For36, While1While2, While4, While7, While11While12,
While22While23, Series1, Series15Series17, Series19, Series21, Series30, Proc4,
Proc8, Proc10, Proc20Proc21, Proc25, Proc40, Minmax1, Minmax4, Minmax6,

Minmax12, Minmax19, Minmax22, Array4, Array7, Array16, Array32, Array47,


Array54, Array63, Array71, Array79, Array89, Array92, Array108, Array112,
Array116, Array134, Matrix7, Matrix24, Matrix36, Matrix53, Matrix74, Matrix82,
Matrix88, Matrix100, String9String10, String19, String29, String41, String44,
String63, String70, File2, File10, File25, File27, File41, File43, File48, File50,
File58, File61, File63, File67, File74, Text1, Text4, Text16, Text21, Text24, Text34,
Text38, Text42, Text44, Text57, Param1, Param17, Param30, Param40, Param49,
Param53, Param59Param61, Recur1, Recur4Recur5, Recur10, Recur14Recur18,
Recur21, Recur25, Recur27, Dynamic2Dynamic3, Dynamic5, Dynamic8
Dynamic12, Dynamic25, Dynamic30, Dynamic49, Dynamic55, Dynamic59,
Dynamic63, Dynamic70, Dynamic74, Dynamic78.
:
PT4Demo
, ;
PT4Load -
;
PT4Result ,
,

-,
| | Programming Taskbook 4. ,
, ( Tools
Add-Ins).
Programming Taskbook Teacher Pack for Programming Taskbook 4.
,
.
:
PTVarMaker.exe .
, , , ;

. . . Programming Taskbook 4.6

PT4Teach.exe . ,
, ,
;
TeacherPack.chm Teacher Pack Info.
PTVarMaker PT4Teach, , Programming Taskbook,
.
Teacher Pack for Pascal
ABC,
Pascal ABC ( 2.5)
.


, .

, .
Dynamic,
, .
,
( ,

). ; ,
. , ,
.
,
10 10 10
.
, A N 1 -

A1 ,
N AN . , B B1,1 . ,
():
M N 1, M, N.
.
, ,
, . , , .

(
, ). ,
: 1.
, Proc, Param
Dynamic , .
Dynamic :
(. )
C++,
(. (.NET))
.NET
C# Visual Basic .NET. ,
Visual Basic Dynamic .


Programming Taskbook -
, , . ,

. . . Programming Taskbook 4.6

, , , , ,
.
-,
, ,
, [F1] ?
( ,
PT4Demo -,
PT4Load).
/ -
, Programming Taskbook
4.6. - ( , - )
PT4Info,
4.6 Programming Taskbook.

:
procedure GetB(var A: boolean);
procedure GetN(var A: integer);
procedure GetR(var A: real);
procedure GetC(var A: char);
procedure GetS(var A: string);
procedure GetP(var A: PNode);
:
procedure PutB(A: boolean);
procedure PutN(A: integer);
procedure PutR(A: real);
procedure PutC(A: char);
procedure PutS(A: string);
procedure PutP(A: PNode);
PNode . Dymanic.
Pascal ABC
- Read
Write.

C++
:
void GetB(bool& a);
void GetN(int& a);
void GetD(double& a);
void GetC(char& a);
void GetS(char* a);
void GetS(string& a);
void GetP(TNode*& a);
:
void PutB(bool a);
void PutN(int a);
void PutD(double a);
void PutC(char a);
void PutS(char* a);
void PutS(string a);
void PutP(TNode* a);
- pt, . ,
GetN(a); GetD(b); GetS(s);
: pt >> a >> b >> s;
PNode . Dymanic.
Visual Basic
:
Public Sub GetB(ByRef A As Boolean)
Public Sub GetN(ByRef A As Integer)
Public Sub GetD(ByRef A As Double)
Public Sub GetS(ByRef A As String)
:
Public Sub PutB(ByVal A As Boolean)
Public Sub PutN(ByVal A As Integer)
Public Sub PutD(ByVal A As Double)
Public Sub PutS(ByVal A As String)

10

. . . Programming Taskbook 4.6

GetS PutS -
, - ( Visual Basic ).
.NET (C# VB.NET)
(C#):
public static bool GetBool();
public static int GetInt();
public static double GetDouble();
public static char GetChar();
public static string GetString();
public static Node GetNode();
(VB.NET):
Public Shared Function GetBool() As Boolean
Public Shared Function GetInt() As Integer
Public Shared Function GetDouble() As Double
Public Shared Function GetChar() As Char
Public Shared Function GetString() As String
Public Shared Function GetNode() As Node
(C#):
public static void Put(params object[] a);
(VB.NET):
Public Shared Sub Put(ParamArray a() As Object)
- .NET
PT, , . PT
,
Solve , PT (, ,
- ).
Put . ( ,
, ).
Node . Dymanic .NET.

11

,
.
Begin1 . a. P = 4a.
Begin2 . a. S = a2 .
Begin3 . a b. S = ab
P = 2(a + b).
Begin4 . d. L = d.
3.14.
Begin5 . a. V = a3
S = 6a2 .
Begin6 . a, b, c .
V = abc S = 2(ab + bc + ac).
Begin7 . L S R:
L = 2R,
S = R2 .
3.14.
Begin8 . a b. : (a + b)/2.
Begin9 . a b.

, : ab.
Begin10 . . , ,
.
Begin11 . . , ,
.
Begin12 . a b. c P:
c = a2 + b2 ,
P = a + b + c.

Begin13 . R1 R2 (R1 > R2 ).


S 1 S 2 , S 3 ,
R1 , R2 :
S 1 = (R1 )2 ,
S 2 = (R2 )2 ,
S3 = S1 S2.
3.14.
Begin14 . L . R S ,
, , L = 2R, S = R2 .
3.14.

12

. . . Programming Taskbook 4.6

Begin15 . S . D L ,
, , L = 2R, S = R2 .
3.14.
Begin16 . x1 x2 : |x2 x1 |.
Begin17 . A, B, C . AC
BC .
Begin18 . A, B, C . C
A B. AC BC.
Begin19 . :
(x1 , y1 ), (x2 , y2 ). .
.
Begin20 .
(x1 , y1 ) (x2 , y2 ) .

q
(x2 x1 )2 + (y2 y1 )2 .
Begin21 . : (x1 , y1 ), (x2 , y2 ), (x3 , y3 ).
, (. Begin20).
a, b, c :

S = p(p a)(p b)(p c),


p = (a + b + c)/2 .
Begin22 . A B
A B.
Begin23 . A, B, C. , A B, B C, C A, A,
B, C.
Begin24 . A, B, C. , A C, C B, B A, A,
B, C.
Begin25 . y = 3x6 6x2 7 x.
Begin26 . y = 4(x3)6 7(x3)3 + 2
x.
Begin27 . A. A8 , . A2 ,
A4 , A8 . A.
Begin28 . A. A15 , -

13

.
A2 , A3 , A5 , A10 , A15 . A.
Begin29 . (0 < < 360).
, , 180 = .
3.14.
Begin30 . (0 < < 2).
, , 180 = .
3.14.
Begin31 . T .
. T C T F :
T C = (T F 32)5/9.

Begin32 . T . . T C T F :
T C = (T F 32)5/9.

Begin33 . , X A . ,
1 Y .
Begin34 . , X A , Y B . , 1 ,
1 , .
Begin35 . V /, U /
(U < V ). T 1 , ( )
T 2 . S, ( = ).
,
.
Begin36 . V 1 /, V 2 /, S . T ,
. , ;
= .
Begin37 . V 1 /, V 2 /, S . T ,
.

14

. . . Programming Taskbook 4.6

,
; = .
Begin38 . Ax + B = 0, A B ( A 0).
Begin39 . Ax2 + Bx + C = 0, A, B, C ( A 0), , . , .

x1, 2 = (B D)/(2A),
D , B2 4AC.
Begin40 .
A1 x + B1 y = C 1 ,
A2 x + B2 y = C 2 ,
A1 , B1 , C 1 , A2 , B2 , C 2 , ,
.
x = (C 1 B2 C 2 B1 )/D,
y = (A1 C 2 A2 C 1 )/D,
D = A1 B2 A2 B1 .


. , (
, . .), .
Integer1 . L .
, (1 = 100 ).
Integer2 . M . ,
(1 = 1000 ).
Integer3 . . ,
,
(1 = 1024 ).
Integer4 . A B (A > B). A B
( ). ,
B, A.

15

Integer5 . A B (A > B). A


B (
). ,
A.
Integer6 . . (), ().
, .
Integer7 . . .
Integer8 . . , .
Integer9 . . ,
().
Integer10 . .
(), ().
Integer11 . . .
Integer12 . . , .
Integer13 . .
. .
Integer14 . .
. .
Integer15 . . , (, 123
213).
Integer16 . . , (, 123
132).
Integer17 . , 999. , ,
.
Integer18 . , 999. , ,
.
Integer19 . N (N ).
, .

16

. . . Programming Taskbook 4.6

Integer20 . N (N ).
, .
Integer21 . N (N ).
, .
Integer22 . N (N ).
, .
Integer23 . N (N ).
, .
Integer24 . : 0 ,
1 , 2 , . . . , 6 . K,
1365. K-
, , 1 .
Integer25 . : 0 ,
1 , 2 , . . . , 6 . K,
1365. K-
, , 1 .
Integer26 . : 1 , 2 , . . . , 6 , 7 . K,
1365. K-
, , 1 .
Integer27 . : 1 , 2 , . . . , 6 , 7 . K,
1365. K-
, , 1 .
Integer28 . : 1 , 2 , . . . , 6 , 7 . K,
1365, N, 17.
K- , ,
1 N.
Integer29 . A, B, C. A B
C ( ). ,
, .
Integer30 . ( ). , , , ,
20 1901 .

17



TRUE,
, FALSE . , ( , . .),
.
Boolean1 . A. : A .
Boolean2 . A. : A .
Boolean3 . A. : A .
Boolean4 . : A, B. :
A > 2 B 3.
Boolean5 . : A, B. :
A 0 B < 2.
Boolean6 . : A, B, C. : A < B < C.
Boolean7 . : A, B, C. : B A C.
Boolean8 . : A, B. :
A B .
Boolean9 . : A, B. :
A B .
Boolean10 . : A, B. : A B .
Boolean11 . : A, B. : A B .
Boolean12 . : A, B, C. : A, B, C .
Boolean13 . : A, B, C. : A, B, C .
Boolean14 . : A, B, C. : A, B, C .

18

. . . Programming Taskbook 4.6

Boolean15 . : A, B, C. : A, B, C .
Boolean16 . . : .
Boolean17 . . : .
Boolean18 . :
.
Boolean19 . :
.
Boolean20 . . :
.
Boolean21 . . :
.
Boolean22 . . :
.
Boolean23 . . : .
Boolean24 . A, B, C ( A 0). D = B2 4AC, :
Ax2 + Bx + C = 0 .
Boolean25 . x, y. :
(x, y) .
Boolean26 . x, y. :
(x, y) .
Boolean27 . x, y. :
(x, y) .
Boolean28 . x, y. :
(x, y) .
Boolean29 . x, y, x1 , y1 , x2 , y2 . : (x, y) ,
(x1 , y1 ),
(x2 , y2 ), .
Boolean30 . a, b, c, . : -

19

a, b, c .
Boolean31 . a, b, c, . : a, b, c .
Boolean32 . a, b, c, . : a, b, c .
Boolean33 . a, b, c. :
a, b, c.
Boolean34 . x, y ( , 18). , (1, 1)
, : .
Boolean35 . x1 ,
y1 , x2 , y2 ( , 18).
: .
Boolean36 . x1 , y1 ,
x2 , y2 ( , 18). : .
Boolean37 . x1 ,
y1 , x2 , y2 ( , 18).
: .
Boolean38 . x1 ,
y1 , x2 , y2 ( , 18).
: .
Boolean39 . x1 , y1 ,
x2 , y2 ( , 18). : .
Boolean40 . x1 ,
y1 , x2 , y2 ( , 18).
: .

20

. . . Programming Taskbook 4.6


If1. . ,
1; . .
If2. . ,
1; 2. .
If3. . ,
1; , 2; ,
10. .

If4 . . .
If5. .
.
If6 . . .
If7. . .
If8 . . , .
If9. : A, B. , A ,
B . A B.
If10. : A B. ,
, ,
.
A B.
If11. : A B. ,
, ,
.
A B.
If12 . . .
If13. . ( ,
).
If14. . ,
.
If15. . .
If16. : A, B, C.
, ; .

21

A, B, C.
If17. : A, B, C.
, ; .
A, B, C.
If18. , , . ,
.
If19. , ,
. ,
.
If20. : A, B, C. ,
(B C) A,
A.
If21. . , 0. , OX OY, 1
2. , 3.

If22 . , OX OY.
,
.
If23. ,
. .
If24. x f,
:
f (x)

= 2sin(x), x > 0,
6 x, x 0.
If25. x f, :
f (x)

2x, x < 2 x > 2,


3x, .

If26 . x f,
:

22

. . . Programming Taskbook 4.6

x, x 0,
f (x) = x2 , 0 < x < 2,
4, x 2.
If27. x f,
:
0, x < 0,
f (x) =
1, x [0, 1), [2, 3), . . . ,
1, x [1, 2), [3, 4), . . . .
If28. ( ).
, , 365 ,
366 . , 4,
, 100 400
(, 300, 1300 1900 , 1200 2000
).
If29. . -
, , . .
If30. , 1999. ,
. .


Case1. 17.
, (1 , 2 . .).
Case2 . K. - , K (1 , 2 , 3 , 4 , 5 ). K 15,
.
Case3. 112 (1 , 2 . .). (,
, , ).
Case4 . 112 (1 , 2
. .). .

23

Case5.
: 1 , 2 , 3 , 4 .
N ( 14) A
B (B 0).
.
Case6. : 1 ,
2 , 3 , 4 , 5 .
( 15)
( ). .
Case7. : 1 ,
2 , 3 , 4 , 5 . ( 15)
( ). .
Case8. : D () M (), . D M ,
.
Case9 . : D () M (), . D M ,
.
Case10 . ( ,
, , ) : 0 , 1 , 1
. C N
. .
Case11. ( ,
, , ) : 1 , 1 , 2
180 . C N 1
N 2 .
.
Case12. : 1 R, 2 D = 2R, 3 L = 2R, 4 S = R2 . .
( ).
3.14.

24

. . . Programming Taskbook 4.6

Case13.
: 1 a, 2 c = a 2, 3
h, (h = c/2), 4 S = ch/2.
.
( ).
Case14. :
1 a, 2 R1

(R1 = a 3/6),
3 R2 (R2 = 2R1 ), 4
2
S = a 3/4. .
(
).
Case15. : 1 ,
2 , 3 , 4 . , ,
: 11 , 12 , 13 , 14 .
: N (6 N 14) M
(1 M 4).
, , . .
Case16. 2069, ( ).
- , , : 20 , 32
, 41 .
Case17. 1040, . -
, , : 18 ,
23 , 31 .
Case18 . 100999. -
, : 256 , 814 .
Case19. 60- , 12 , : , ,
, . : , , , , , , , , ,
, . ,
1984 : .

25

Case20. : D () M (), . , : (20.118.2), (19.220.3), (21.319.4), (20.4


20.5), (21.521.6), (22.622.7), (23.722.8), (23.822.9), (23.922.10), (23.1022.11), (23.1121.12), (22.1219.1).


For1. K N (N > 0). N K.
For2. A B (A < B).
, A B ( A B),
N .
For3. A B (A < B).
, A B ( A B),
N .
For4. 1 . 1,
2, . . . , 10 .
For5 . 1 . 0.1,
0.2, . . . , 1 .
For6. 1 . 1.2,
1.4, . . . , 2 .
For7. A B (A < B).
A B .
For8. A B (A < B).
A B .
For9. A B (A < B).
A B .
For10. N (> 0).
1 + 1/2 + 1/3 + . . . + 1/N
( ).
For11. N (> 0).
N 2 + (N + 1)2 + (N + 2)2 + . . . + (2N)2
( ).
For12 . N (> 0).
1.1 1.2 1.3 . . .

26

. . . Programming Taskbook 4.6

(N ).
For13 . N (> 0).
1.1 1.2 + 1.3 . . .
(N , ). .
For14. N (> 0). ,
:
N 2 = 1 + 3 + 5 + . . . + (2N 1).
( 1
N).
For15 . A N (> 0). A N:
AN = AA . . . A
( A N ).
For16 . A N (> 0).
, A 1 N.
For17. A N (> 0).
,
1 + A + A2 + A3 + . . . + AN .
For18. A N (> 0).
,
1 A + A2 A3 + . . . + (1)N AN .
.
For19 . N (> 0).
N! = 12. . .N
(N). ,
.
For20 . N (> 0). ,
1! + 2! + 3! + . . . + N!
( N! N
1 N: N! = 12. . .N). ,
.
For21. N (> 0). ,
1 + 1/(1!) + 1/(2!) + 1/(3!) + . . . + 1/(N!)

27

( N! N
1 N: N! = 12. . .N). e = exp(1).
For22. X N (> 0).

1 + X + X 2 /(2!) + . . . + X N /(N!)
(N! = 12. . .N).
exp X.
For23. X N (> 0).

X X 3 /(3!) + X 5 /(5!) . . . + (1)N X 2N +1 /((2N+1)!)


(N! = 12. . .N).
sin X.
For24. X N (> 0).

1 X 2 /(2!) + X 4 /(4!) . . . + (1)N X 2N /((2N)!)


(N! = 12. . .N).
cos X.
For25. X (|X | < 1) N (> 0).

X X 2 /2 + X 3 /3 . . . + (1)N 1 X N /N.
ln 1 + X.
For26. X (|X | < 1) N (> 0).

X X 3 /3 + X 5 /5 . . . + (1)N X 2N +1 /(2N+1).
arctg
X.
For27. X (|X | < 1) N (> 0).

X + 1X 3 /(23) + 13X 5 /(245) + . . . +
+ 13. . .(2N1)X 2N +1 /(24. . .(2N)(2N+1)).
arcsin
X.
For28. X (|X | < 1) N (> 0).

28

. . . Programming Taskbook 4.6

1 + X /2 1X 2 /(24) + 13X 3 /(246) . . . +


+ (1)N 1 13. . .(2N3)X N /(24. . .(2N)).

1+X .
For29. N (> 1) :
A, B (A < B). [A, B] N . H
,
A, A + H, A + 2H, A + 3H, . . . , B,
[A, B].
For30. N (> 1) :
A, B (A < B). [A, B] N . H
, F(X ) = 1 sin(X )
, [A, B]:
F(A), F(A + H), F(A + 2H), . . . , F(B).
For31. N (> 0). AK
:
A0 = 2,
AK = 2 + 1/AK1 , K = 1, 2, . . . .
A1 , A2 , . . . , AN .
For32. N (> 0). AK
:
A0 = 1,
AK = (AK1 + 1)/K, K = 1, 2, . . . .
A1 , A2 , . . . , AN .
For33 . N (> 1). F K
( ) :
F 1 = 1,
F 2 = 1,
F K = F K2 + F K1 , K = 3, 4, . . . .
F 1 , F 2 , ..., F N .
For34. N (> 1). AK
:
A1 = 1,
A2 = 2,
AK = (AK2 + 2AK1 )/3, K = 3, 4, . . . .
A1 , A2 , . . . , AN .
For35. N (> 2). AK :
A1 = 1,
A2 = 2,
A3 = 3,
AK = AK1 + AK2 2AK3 , K = 4, 5, . . . .
A1 , A2 , . . . , AN .

29


For36 . N K.
1K + 2K + . . . + N K .
,
.
For37. N (> 0).
11 + 22 + . . . + N N .
,
.
For38. N (> 0).
1N + 2N 1 + . . . + N 1 .
,
.
For39. A B (A < B).
A B ;
, (, 3 3 ).
For40. A B (A < B). A B
; A 1 , A + 1
2 . .


While1 . A B (A > B). A
B (
). ,
A.
While2 . A B (A > B). A B ( ). ,
B, A.
While3. N K.
, N K,

30

. . . Programming Taskbook 4.6

.
While4 . N (> 0). 3,
TRUE, FALSE.
While5. N (> 0), 2:
N = 2K . K .
While6. N (> 0). N:
N!! = N(N2)(N4). . .
( 2, N , 1, N ). , .
While7 . N (> 0).
K, N: K 2 > N.
.
While8. N (> 0). K,
N: K 2 N.
.
While9. N (> 1). K,
3K > N.
While10. N (> 1). K,
3K < N.
While11 . N (> 1). K,
1 + 2 + . . . + K N,
.
While12 . N (> 1). K,
1 + 2 + . . . + K N,
.
While13. A (> 1). K,
1 + 1/2 + . . . + 1/K A, .
While14. A (> 1). K,
1 + 1/2 + . . . + 1/K A, .
While15. 1000 . P (P
, 0 < P < 25). P ,
1100 ., K ( ) S (

31

).
While16. - ,
10 . P (P , 0 < P < 50).
P ,
200 , K ()
S ( ).
While17. N (> 0).
, ,
( ).
While18. N (> 0).
, .
While19. N (> 0). , , N
.
While20. N (> 0).
, N
2. , TRUE, FALSE.
While21. N (> 0).
, N
. , TRUE,
FALSE.
While22 . N (> 1). ,
, 1 , TRUE,
FALSE.
While23 . A B.
(), :
(A, B) = (B, A mod B), B 6= 0;
(A, 0) = A,
mod .
While24. N (> 1). F K
:
F 1 = 1,
F 2 = 1,
F K = F K2 + F K1 , K = 3, 4, . . . .
, N . ,
TRUE, FALSE.
While25. N (> 1). , N
( While24).

32

. . . Programming Taskbook 4.6

While26. N (> 1), : N = F K


( While24).
F K1 F K+1 .
While27. N (> 1), : N = F K
( While24).
K N.
While28. (> 0).
AK :
A1 = 2,
AK = 2 + 1/AK1 , K = 2, 3, . . . .
K,
|AK AK1 | < , , AK1 AK .
While29. (> 0).
AK :
A1 = 1,
A2 = 2,
AK = (AK2 + 2AK1 )/3, K = 3, 4, . . . .
K,
|AK AK1 | < , , AK1 AK .
While30. A, B, C. A B
C ( ). ,
. .

,
( , N
). (Series29Series40)
K .
Series1 . . .
Series2. . .
Series3. . .
Series4. N N .
.
Series5. N N
.
( ),
.

33

Series6. N N
. ( ),
.
Series7. N N .
(
), .
Series8. N N .
K .
Series9. N N .
K
.
Series10. N N .
, TRUE;
FALSE.
Series11. K, N N .
, K, TRUE;
FALSE.
Series12. ; 0. .
Series13. ; 0. . , 0.
Series14. K ;
0. , K.
Series15 . K ;
0. , K. , 0.
Series16 . K ;
0. ,
K. , 0.
Series17 . B, N N , .
B, .
Series18. N N ,
. .

34

. . . Programming Taskbook 4.6

.
Series19 . N (> 1) N .
, , K
.
Series20. N (> 1) N .
, , K
.
Series21 . N (> 1) N . , .
, TRUE, FALSE.
Series22. N (> 1) N .
, 0;
, .
Series23. N (> 2) N .
,
, ( ).
, 0;
, .
Series24. N N ,
. , (
, 0).
Series25. N N ,
. , (
, 0).

Series26. K, N N : A1 ,
A2 , . . ., AN . K-e :
(A1 )K , (A2 )K , . . ., (AN )K .
Series27. N N : A1 , A2 , . . .,
AN . :
A1 , (A2 )2 , . . ., (AN 1 )N 1 , (AN )N .

35

Series28. N N : A1 , A2 , . . .,
AN . :
(A1 )N , (A2 )N 1 , . . ., (AN 1 )2 , AN .
Series29. K, N, K N . ,
.
Series30 . K, N, K N . .
Series31. K, N, K N . , 2.
, 0.
Series32. K, N, K N .
, 2, 0, .
Series33. K, N, K N .
, 2, 0, .
Series34. K, N, K N . : 2, ;
, 0.
Series35. K, K .
0. .
.
Series36. K, K .
, 0. ,
.
Series37. K, K .
, 0. ,
.
Series38. K, K .
, -

36

. . . Programming Taskbook 4.6

0. : , 1;
, 1;
, 0.
Series39. K, K .
, 0. ( Series23).
Series40. K, K .
, 0. : (. Series23), ;
, .



Proc1. PowerA3(A, B), A B (A , B
; ).
.
Proc2. PowerA234(A, B, C, D), ,
A B, C D (A , B, C, D
; ).
, .
Proc3. Mean(X, Y, AMean, GMean),

AMean = (X +Y )/2

GMean = X Y X Y (X Y ,
AMean GMean ).

(A, B), (A, C), (A, D), A, B, C, D.
Proc4 . TrianglePS(a, P, S),
a
2
P = 3a S = a 3/4

37

(a , P S ; ).
.
Proc5. RectPS(x1 , y1 , x2 , y2 , P, S), P
S , , (x1 , y1 ), (x2 , y2 )
(x1 , y1 , x2 , y2 , P S ). .
Proc6. DigitCountSum(K, C, S), C
K, S (K ,
C S ).
.
Proc7. InvertDigits(K),
K (K
, ).

.
Proc8 . AddRightDigit(D, K), K D (D
, 09, K ,
). K D1 D2 ,
.
Proc9. AddLeftDigit(D, K), K D (D
, 19, K ,
). K D1 D2 ,
.
Proc10 . Swap(X, Y ), X Y (X Y ,
). A, B,
C, D : A B, C
D, B C A, B, C, D.
Proc11. Minmax(X, Y ), X

38

. . . Programming Taskbook 4.6

X Y, Y
(X Y , ). , A, B, C, D.
Proc12. SortInc3(A, B, C), A, B, C , (A, B, C ,
). : (A1 , B1 , C 1 )
(A2 , B2 , C 2 ).
Proc13. SortDec3(A, B, C), A, B, C , (A, B, C ,
). : (A1 , B1 , C 1 )
(A2 , B2 , C 2 ).
Proc14. ShiftRight3(A, B, C), : A B, B C, C
A (A, B, C ,
).
: (A1 , B1 , C 1 )
(A2 , B2 , C 2 ).
Proc15. ShiftLeft3(A, B, C), : A C, C B, B
A (A, B, C ,
).
: (A1 , B1 , C 1 )
(A2 , B2 , C 2 ).

Proc16. Sign(X ) , X :
1, X < 0;
0, X = 0;
1, X > 0.
Sign(A) + Sign(B)
A B.

39

Proc17. RootsCount(A, B, C) ,
Ax2 + Bx + C = 0 (A, B, C
, A 6= 0).
.
:
D = B2 4AC.
Proc18. CircleS(R) , R (R ).
. R S = R2 . 3.14.
Proc19. RingS(R1 , R2 ) , ,
R1 R2 (R1 R2 , R1 > R2 ).
, . R: S = R2 .
3.14.
Proc20 . TriangleP(a, h), a h,
(a h ).
, .
b
:
b2 = (a/2)2 + h2 .
Proc21 . SumRange(A, B) ,
A B (A B ). A > B,
0.
A B B C, A, B, C.
Proc22. Calc(A, B, Op) ,
A B
. Op: 1 , 2 , 3 , . Calc A B
, N 1 , N 2 , N 3 .
Proc23. Quarter(x, y) ,
, -

40

. . . Programming Taskbook 4.6

(x, y).
.
Proc24. Even(K) , TRUE,
K , FALSE .
10 .
Proc25 . IsSquare(K) ,
TRUE, K (> 0) , FALSE .
10 .
Proc26. IsPower5(K) ,
TRUE, K (> 0) 5, FALSE
. 5
10 .
Proc27. IsPowerN(K, N) ,
TRUE, K (> 0) N (> 1),
FALSE . N (> 1) 10 . IsPowerN
N .
Proc28. IsPrime(N) , TRUE,
N (> 1) , FALSE (, 1, ,
, 1 ). 10 , 1. IsPrime
.
Proc29. DigitCount(K) ,
K. , .
Proc30. DigitN(K, N) , N- K (
). K N, 1. K 1 ,
K 2 , . . ., K 5 DigitN N, 1
5.
Proc31. IsPalindrom(K), TRUE,
K (> 0) ( -

41

), FALSE .
10 .
DigitCount DigitN Proc29 Proc30.
Proc32. DegToRad(D) , , D (D , 0 < D < 360). :
180 = . 3.14.
DegToRad .
Proc33. RadToDeg(R) , , R (R , 0 < R < 2). :
180 = . 3.14.
RadToDeg .
Proc34. Fact(N) , N! = 12. . .N (N > 0 ; ,
N).
.
Proc35. Fact2(N) , :
N!! = 135. . .N, N ;
N!! = 246. . .N, N
(N > 0 ; ,
N). .
Proc36. Fib(N) , N-
F K , :
F 1 = 1,

F 2 = 1,

F K = F K2 + F K1 ,

K = 3, 4, . . . .

Fib, N 1 , N 2 , . . ., N 5 .

42

. . . Programming Taskbook 4.6


Proc37. Power1(A, B) , AB AB = exp(Bln(A)) ( A B ).
A 0. AP , BP , C P ,
P, A, B, C.
Proc38. Power2(A, N) , AN (A , N )
:
A0 = 1;
AN = AA. . .A (N ), N > 0;
AN = 1/(AA. . .A) (|N| ), N < 0.
AK , AL , AM , A, K, L, M.
Proc39. Power1 Power2 ( Proc37 Proc38), Power3(A, B) , AB : B
, Power2(A, Round(B)); Power1(A, B).
AP , BP , C P , P, A, B, C.
Proc40 . Exp1(x, ) ( x,
, > 0),
exp(x):
exp(x) = 1 + x + x2 /(2!) + x3 /(3!) + . . . + xn /(n!) + . . .
(n! = 12. . .n). , .
Exp1 x
.
Proc41. Sin1(x, ) ( x,
, > 0), sin(x):
sin(x) = x x3 /(3!) + x5 /(5!) . . . + (1)n x2n+1 /((2n+1)!) + . . . .
, . Sin1 x
.
Proc42. Cos1(x, ) ( x,
, > 0), cos(x):
cos(x) = 1 x2 /(2!) + x4 /(4!) . . . + (1)n x2n /((2n)!) + . . . .
, .

43

Cos1 x
.
Proc43. Ln1(x, ) ( x,
, |x| < 1, > 0),
ln(1 + x):
ln(1 + x) = x x2 /2 + x3 /3 . . . + (1)n xn+1 /(n+1) + . . . .
, .
Ln1 ln(1 + x) x
.
Proc44. Arctg1(x, ) ( x,
, |x| < 1, > 0),
arctg(x):
arctg(x) = x x3 /3 + x5 /5 . . . + (1)n x2n+1 /(2n+1) + . . . .
, .
Arctg1 arctg(x) x
.
Proc45. Power4(x, a, ) ( x,
a, , |x| < 1; a, > 0),
(1 + x)a :
(1 + x)a = 1 + ax + a(a1)x2 /(2!) + . . . + a(a1). . .(an+1)xn /(n!) + . . . .
, .
Power4 (1 + x)a x a
.
Proc46. NOD2(A, B) ,
() A B,
:
(A, B) = (B, A mod B), B 6= 0;
(A, 0) = A.
(A, B),
(A, C), (A, D), A, B, C, D.
Proc47. NOD2 Proc46,
Frac1(a, b, p, q), a/b p/q (
, a b , p q ).
p/q (. . q > 0).
Frac1 , a/b + c/d, a/b + e/f,
a/b + g/h ( a, b, c, d, e, f, g, h ).
Proc48. , -

44

. . . Programming Taskbook 4.6

A B A(B/(A, B)), (A, B)


A B, NOD2 Proc46,
NOK2(A, B) , A B. NOK2
(A, B), (A, C), (A, D), A, B, C, D.
Proc49. (A, B, C) = ((A, B), C) NOD2 Proc46, NOD3(A, B, C)
, A, B, C.
(A, B, C), (A, C, D) (B, C, D), A,
B, C, D.
Proc50. TimeToHMS(T, H, M, S), T ( ) H, M
S (T , H, M S ).
, ,
T 1 , T 2 , . . ., T 5 .
Proc51. IncTime(H, M, S, T), T , H, M S (H, M S
, T ;
). ( H, M, S)
T. IncTime,
T H, M, S.
Proc52. IsLeapYear(Y ) , TRUE, Y ( ) ,
FALSE . IsLeapYear
Y. , 4, , 100
400.
Proc53. IsLeapYear Proc52,
MonthDays(M, Y ) ,
M- Y (1 M 12, Y > 0 ).
MonthDays Y M 1 , M 2 , M 3 .
Proc54. MonthDays Proc53,
PrevDate(D, M, Y ), , D, M Y,
( D, M, Y

45

). PrevDate
.
Proc55. MonthDays Proc53,
NextDate(D, M, Y ), , D, M Y,
( D, M, Y
). NextDate
.
Proc56. Leng(xA , yA , xB , yB ) , AB
:
q
|AB| = (xA xB )2 + (yA yB )2
(xA , yA , xB , yB ).
AB, AC, AD, A, B, C, D.
Proc57. Leng Proc56,
Perim(xA , yA , xB , yB , xC , yC ) ,
ABC (xA , yA , xB , yB , xC , yC
).
ABC, ABD, ACD, A, B, C, D.
Proc58. Leng Perim Proc56 Proc57,
Area(xA , yA , xB , yB , xC , yC ) ,
ABC

S ABC = p(p|AB|)(p|AC|)(p|BC|),
p . ABC, ABD, ACD, A, B, C, D.
Proc59. Leng Area Proc56 Proc58,
Dist(xP , yP , xA , yA , xB , yB ) ,
D(P, AB) P AB
D(P, AB) = 2S P AB /|AB|,
S P AB PAB.
P AB, AC, BC,
P, A, B, C.
Proc60. Dist Proc59,
Heights(xA , yA , xB , yB , xC , yC , hA , hB , hC ), hA , hB , hC ABC ( ),
A, B, C ( ). ABC, ABD, ACD,

46

. . . Programming Taskbook 4.6

A, B, C, D.


, .
:
,
.
, ( , N
).
Minmax1 . N N .

.
Minmax2. N N , (a, b). .
Minmax3. N N , (a, b).
.
Minmax4 . N N . .
Minmax5. N N (m, v) m v , . , ,
. P

P = m/v.

Minmax6 . N N .

.
Minmax7. N N .

.

47

Minmax8. N N .
.
Minmax9. N N .
.
Minmax10. N N . ( )
.
Minmax11. N N .
( )
.
Minmax12 . N N .
.
, 0.
Minmax13. N N . .
, 0.
Minmax14. B (> 0) .
, B, .
, B, , 0
Minmax15. B, C (0 < B < C) .
, (B, C),
. ,
0.
Minmax16. N N .
, .
Minmax17. N N .
, .
Minmax18. N N .
, . ,
0.
Minmax19 . N N .
.
Minmax20. N N . -

48

. . . Programming Taskbook 4.6

( )
.
Minmax21. N (> 2) N
, N . .
.
Minmax22 . N (> 2) N .
.
Minmax23. N (> 3) N .
.
Minmax24. N (> 1) N .
.
Minmax25. N (> 1) N .
,
, , .
Minmax26. N N . , .
, 0.
Minmax27. N N ,
. ,
,
. ,
.
Minmax28. N N , . ,
, . ,
. ,
0.
Minmax29. N N .
.
Minmax30. N N .
.

49


N , ( N), . ,
, ,
2 10. 1.
, () ,
, ,
() ,
.

, 10.
Array1. N (> 0).
N, N :
1, 3, 5, . . . .
Array2. N (> 0).
N, N-: 2, 4,
8, 16, . . . .
Array3. N (> 1), A D . N, N :
A, A + D, A + 2D, A + 3D, . . . .

Array4 . N (> 1), A D


. N,
N :
A, AD, AD2 , AD3 , . . . .
Array5. N (> 2).
N, N
F K :
F 1 = 1,
F 2 = 1,
F K = F K2 + F K1 , K = 3, 4, . . . .
Array6. N (> 2), A B. N, A,

50

. . . Programming Taskbook 4.6

B, .
Array7 . N. .
Array8. N.
,
K.
Array9. N.
,
K.
Array10. N. ,
.
Array11. A N K (1 K N). , K: AK , A2K , A3K , . . . .
.
Array12. A N (N ).
: A2 , A4 , A6 , . . ., AN .
.
Array13. A N (N ).
: AN , AN 2 , AN 4 , . . .,
A1 . .
Array14. A N.
( ), ( ):
A2 , A4 , A6 , . . ., A1 , A3 , A5 , . . . .
.
Array15. A N.
,
:
A1 , A3 , A5 , . . ., A6 , A4 , A2 .
.
Array16 . A N. :
A1 , AN , A2 , AN 1 , A3 , AN 2 , . . . .
Array17. A N. :
A1 , A2 , AN , AN 1 , A3 , A4 , AN 2 , AN 3 , . . . .

51


,
, , .
.
Series Minmax, .
, , ,
, .
Array18. A 10.
AK ,
AK < A10 . , 0.
Array19. A 10.
AK ,
A1 < AK < A10 . , 0.
Array20. N K L (1 K L N).
K L .
Array21. N K L (1 K L N).
K L
.
Array22. N K L (1 < K L N).
, K L
.
Array23. N K L (1 < K L N).
,
K L .
Array24. N,
. , (. Array3). , ,
0.
Array25. N. ,
(. Array4).
, , 0.
Array26. N. ,
. , 0, ,

52

. . . Programming Taskbook 4.6

, .
Array27. N. , . ,
0, , ,
.
Array28. A N. : A2 , A4 , A6 , . . . .
Array29. A N. : A1 , A3 , A5 , . . . .
Array30. N. ,
, .
.
Array31. N. ,
, .
.
Array32 . N. ( ,
).
Array33. N. ( ,
).
Array34. N. ( Array32).
Array35. N. ( Array33).
Array36. N. , , (
Array32 Array33). , 0
( ).
Array37. N. ,
.
Array38. N. ,
.
Array39. N. -

53

( ,
).
Array40. R A N. , R ( AK ,
|AK R| ).
Array41. N. ,
, .
Array42. R N. , R,
(
Array40).
Array43. N, ( ).
.
Array44. N, .
.
Array45. N.
( )
.
Array46. R N.
, R, (
Array40).
Array47 . N.
.
Array48. N. .
Array49. N. , 1 N, 0;
.
Array50. A N,
( Array49).
, AI AJ ,
: AI > AJ I < J.

54

. . . Programming Taskbook 4.6


Array51. A B N.
A,
B.
Array52. A N. B
, :
BK

= 2AK , AK < 5,
AK /2 .
Array53. A B N.
C ,
A B .
Array54 . A N. B (
) B .
Array55. A N ( 15).
B (1, 3, . . .) B .
.
Array56. A N ( 15).
B , (3, 6, . . .), B
. .
Array57. A N. B
, :
A2 , A4 , A6 , . . ., A1 , A3 , A5 , . . . .
.
Array58. A N. B
: BK
A 1 K.
Array59. A N. B
: BK A 1 K.
Array60. A N. B
: BK

55

A K N.
Array61. A N. B
: BK A K N.
Array62. A N. B C:
B A, C
( ).
B,
C.
Array63 . A B 5,
. ,
C ( 10) .
Array64. A, B C N A , N B , N C
, . , D
( N A + N B + N C ) .

.

Array65. A N K (1 K N).
, AK .
Array66. N. ,
, .
, .
Array67. N. , ,
. ,
.
Array68. N. .

56

. . . Programming Taskbook 4.6

Array69. N (N ).
, . .
Array70. N (N ).
.
Array71 . N. .
Array72. A N K L (1 K < L N). ,
AK AL , .
Array73. A N K L (1 K < L N). ,
AK AL , .
Array74. N. , (
).
Array75. N.
, , .
Array76. N. (
, ).
Array77. N. ( , ).
Array78. N.
.
Array79 . N.
( A1 A2 , A2 A3 , . . ., AN 1 AN , a
).
0.
Array80. N.
( AN AN 1 , AN 1 AN 2 , . . ., A2
A1 , a ).
0.
Array81. N K (1 K < N).
K ( A1
AK+1 , A2 AK+2 , . . ., AN K AN , K
). K

57

0.
Array82. N K (1 K < N).
K ( AN
AN K , AN 1 AN K1 , . . ., AK+1 A1 , K
). K
0.
Array83. N.
( A1 A2 , A2 A3 , . . .,
AN A1 ).
Array84. N.
( AN AN 1 , AN 1
AN 2 , . . ., A1 AN ).
Array85. A N K (1 K 4, K < N).
K
( A1 AK+1 , A2 AK+2 , . . ., AN AK ).
4 .
Array86. A N K (1 K 4, K < N).
K
( AN AN K , AN 1 AN K1 , . . ., A1 AN K+1 ).
4 .
Array87. N, , , . ,
.
Array88. N, , ,
. , .
Array89 . N, , , . , , , .

Array90. N K (1 K N).
K.
Array91. N K L (1 K < L N).
K L
.

58

. . . Programming Taskbook 4.6

Array92 . N. .
Array93. N (> 2).
(2, 4, . . .). .
Array94. N (> 2).
(1, 3, . . .). .
Array95. N. , .
Array96. N. , .
Array97. N. , .
Array98. N. , ,
.
Array99. N. , ,
.
Array100. N. , ,
.
Array101. N K (1 K N). K
.
Array102. N K (1 K N).
K
.
Array103. N.
.
Array104. N K M (1 K N,
1 M 10). K M
.
Array105. N K M (1 K N,
1 M 10). K M

59

.
Array106. N.
(2, 4, . . .). .
Array107. N.
(1, 3, . . .). .
Array108 . N.
.
Array109. N.
.
Array110. N.
.
Array111. N.
.

Array112 . A N ( 6). ( ): , (A1 A2 , A2 A3


. .) , ;
N 1 . .
,
1.
Array113. A N ( 6).
:
(N-) ;
N 1 , 1
.
Array114. A N ( 6).
: A1 A2 ,
, , ; A3
( ) ,
; ,
( 2 N-).

60

. . . Programming Taskbook 4.6

,
A0 .
Array115. A N. , ,
. (. Array112), : I, 1 N; A,
A I 1 I 2 , I 2 I 3 , . . .
I,
. N 1 ,
I .

Array116 . A N.
,
( 1).
B C , B
, C ,
.
Array117. N.
(
Array116).
Array118. N.
(
Array116).
Array119. N. , (
Array116).
Array120. N,
, 1. ,
(
Array116).
Array121. K (> 0) N. , K (
Array116). K,

61

.
Array122. K (> 1) N. K (
Array116). K, .
Array123. K (> 1) N. K ( Array116). K,
.
Array124. K (> 0) N. K ( Array116). K,
.
Array125. L (> 1) N. , L,
( Array116).
Array126. L (> 0) N. , L,
( Array116).
Array127. L (> 0) N. , L,
( Array116).
Array128. N. , ( Array116).
Array129. N. , ( Array116).
Array130. N. , (
Array116).


: , . (.

62

. . . Programming Taskbook 4.6

Param64).
Array131. A N B ( x, y). A,
B. R (x1 , y1 )
(x2 , y2 ) :
q
R = (x2 x1 )2 + (y2 y1 )2 .
Array132. A N (
x, y). , ,
, .
, .
Array133. A N (
x, y). ,
, , .
, .
Array134 . A N ( x, y).
( ,
A).
Array135. A B, N 1 N 2
( x, y).
,
( A,
B).
Array136. A N (N > 2, x, y). ,
, .
Array137. A N (N > 2, x, y). ,
A, ( ,
A).
Array138. A N (N > 2, x, y). ,
A, ( ,
A).

()

63

Array139. A N x, y.
:
(x1 , y1 ) < (x2 , y2 ), x1 < x2 , x1 = x2 y1 < y2 .

.
Array140. A N x, y.
:
(x1 , y1 ) < (x2 , y2 ), x1 + y1 < x2 + y2 , x1 + y1 = x2 + y2
x1 < x2 .

.

()
M N ,
- ( M N), (
MN). ,
, ,
, 2 10.
, - 1.
.
M -
M M.
, ,
, ,
() ,
.

, 10 10.

64

. . . Programming Taskbook 4.6

Matrix1. M N. M N, I-
10I (I = 1, . . ., M).
Matrix2. M N. M N, J -
5J (J = 1, . . ., N).
Matrix3. M, N M . M N,
( ).
Matrix4. M, N N . M N,
( ).
Matrix5. M, N, D M . M N,
,

D (
).
Matrix6. M, N, D N .
M N, ,
,
D (
).
Matrix7 . M N K (1 K M).
K- .
Matrix8. M N K (1 K N).
K- .
Matrix9. M N. ,
(2, 4, . . .).
, .
Matrix10. M N. ,
(1, 3, . . .). , .
Matrix11. M N.
: , ,

()

65

, . .
Matrix12. M N.
: , ,
, . .
Matrix13. A M. A1,1 , (): ; , ( ) ; ;
. .; AM,1 .
Matrix14. A M. A1,1 , (): ; , ( )
; ;
. .; A1,M .
Matrix15. A M (M ). A1,1 ,
: , ,
, , . .;
.
Matrix16. A M (M ). A1,1 ,
: , ,
, , . .;
.

Matrix17. M N K (1 K M).
K- .
Matrix18. M N K (1 K N).
K- .
Matrix19. M N.
.
Matrix20. M N.
.

66

. . . Programming Taskbook 4.6

Matrix21. M N. (1, 3, . . .) .
.
Matrix22. M N.
(2, 4, . . .) .
.
Matrix23. M N.
.
Matrix24 . M N.
.
Matrix25. M N.
,
.
Matrix26. M N. ,
.
Matrix27. M N. .
Matrix28. M N. .
Matrix29. M N. ,
.
Matrix30. M N. ,
.
Matrix31. M N.
,
.
Matrix32. M N.
, ( ).
, 0.
Matrix33. M N. ,
( ).

()

67

, 0.
Matrix34. M N. , . ,
0.
Matrix35. M N.
, .
, 0.
Matrix36 . M N,
0 100. , ,
. , .
Matrix37. M N, 0 100. , ,
. ,
.
Matrix38. M N.
, .
Matrix39. M N.
, .
Matrix40. M N. ,
.
Matrix41. M N. ,
.
Matrix42. M N. ,
.
Matrix43. M N. , .
Matrix44. M N.
, , .
, 0.
Matrix45. M N. , ,

68

. . . Programming Taskbook 4.6

. ,
0.
Matrix46. M N. , .
, 0.

( Matrix74
Matrix75) .
Matrix47. M N K 1 K 2
(1 K 1 < K 2 M). K 1
K 2.
Matrix48. M N K 1 K 2
(1 K 1 < K 2 N). K 1
K 2.
Matrix49. M N. ,
.
Matrix50. M N. ,
.
Matrix51. M N. , .
Matrix52. M N. , .
Matrix53 . M N. 1 ,
. , .
Matrix54. M N. N , . , .
Matrix55. M N (M ). .
Matrix56. M N (N ).
.

()

69

Matrix57. M N (M N ).
.
Matrix58. M N (M N ).
.
Matrix59. M N. (
1 M, 2 M 1 . .).
Matrix60. M N. (
1 N, 2 N 1 . .).
Matrix61. M N K (1 K M).
K.
Matrix62. M N K (1 K N).
K.
Matrix63. M N. , .
Matrix64. M N. , .
Matrix65. M N. , . ,
.
Matrix66. M N. , . ,
.
Matrix67. M N, ,
. , . ,
.
Matrix68. M N K (1 K M).
K .
Matrix69. M N K (1 K N).
K .
Matrix70. M N. ,
.
Matrix71. M N. ,
.

70

. . . Programming Taskbook 4.6

Matrix72. M N. , , .
, .
Matrix73. M N. , , .
, .
Matrix74 . M N.
, . .
.
Matrix75. M N. , .
x .
.
Matrix76. M N. ,
.
Matrix77. M N. ,
.
Matrix78. M N. ,
.
Matrix79. M N. ,
.

Matrix80. A M.
, , :
A1,1 , A2,2 , A3,3 , . . ., AM,M .
Matrix81. A M. , ,
:
A1,M , A2,M 1 , A3,M 2 , . . ., AM,1 .

Matrix82 . A M.
, (
A1,M ).

()

71

Matrix83. A M.
, (
A1,1 ).
Matrix84. A M. , (
A1,M ).
Matrix85. A M. , (
A1,1 ).
Matrix86. A M.
, ( A1,M ).
Matrix87. A M. , ( A1,1 ).
Matrix88 . M. ,
. .
Matrix89. M. ,
. .
Matrix90. M. , .
.
Matrix91. M. , .
.
Matrix92. M. ,
. .
Matrix93. M. ,
. .
Matrix94. M. ,
( )
( ).
.
Matrix95. M. ,

72

. . . Programming Taskbook 4.6

( )
( ).
.
Matrix96. A M. ( , A1,2
A2,1 , A1,3 A3,1 . .). .
Matrix97. A M. (
, A1,1
AM,M , A1,2 AM 1,M . .).
.
Matrix98. A M. 180
( A1,1 AM,M , A1,2
AM,M 1 . .). .
Matrix99. A M. 90
, (
A1,1 AM,1 , AM,1 AM,M . .). .
Matrix100 . A M.
90 , (
A1,1 A1,M , A1,M AM,M . .). .


,
.

.
String1. C. ( ).
String2. N (32 N 126). , N.

73

String3. C. ,
C , C.
String4. N (1 N 26). N (
) .
String5. N (1 N 26). N (
) (
z).
String6. C, ( ). C , digit, lat, rus.
String7. . .
String8. N (> 0) C. N,
C.
String9 . N (> 0) C 1 C 2 .
N, C 1 C 2 ,
C1.
String10 . . , , .
String11. S. , S, .
String12. S N (> 0). , S, N
* ().
.

String13. . .
String14. .
.
String15. .
.
String16. .
.
String17. . ( , ) .

74

. . . Programming Taskbook 4.6

String18. . ( , ) , .
String19 . . ,
1, ( ) 2;
, 0. ,

..
String20. . ,
( ).
String21. . ,
( ).
String22. , .
.
String23. ,
<><>. . .<>,
+ (, 4+728). ( ).
String24. , . ,
.
String25. , . ,
.
.

, , ,

. String32, String35 String38, ,
, ( String32 String35) ( String38)

.
String26. N (> 0) S. S
N : S N,

75

, S N,
. ().
String27. N 1 N 2 S 1 S 2 . , N 1
S 1 N 2 S 2 ( ).
String28. C S. C
S.
String29 . C S, S 0 . C
S S 0 .
String30. C S, S 0 . C
S S 0 .
String31. S S 0 . , S 0 S.
, TRUE, , FALSE.
String32. S S 0 . S 0 S.
String33. S S 0 . S , S 0 . , S
.
String34. S S 0 . S ,
S 0 . , S
.
String35. S S 0 . S , S 0 . , S
.
String36. S, S 1 S 2 . S
S 1 S 2 .
String37. S, S 1 S 2 . S
S 1 S 2 .
String38. S, S 1 S 2 . S S 1
S 2 .
String39. , .
,
. ,
.
String40. , . ,

76

. . . Programming Taskbook 4.6

. ,
.

,
.
String41 . , ,
( ). .
String42. , , ( ). , .
String43. , ,
( ). , .
String44 . , ,
( ). , .
String45. , ,
( ). .
String46. , ,
( ). .
String47. , ,
( ). , ,
. (). .
String48. , , ( ).
,
. (). , ...
.
String49. , , ( ).
,
. (). ,

77

...
.
String50. , ,
( ). , ,
.
String51. , ,
( ).
, , .
String52. - .
, .
,
/ . , , .
String53. - .
.
String54. - .
.
String55. - .
. ,
. , ,
, / .
String56. - .
. ,
. , ,
, / .
String57. - . , .

String58. , , ,
(), .
( ).
String59. , , ,
(), .

78

. . . Programming Taskbook 4.6

( ).
String60. , . ( \).
, \.
String61. , . ( \). , \.
String62. - . ,
( , ,
, . .). (
). .
String63 . - K (0 < K < 10).
,
, K-
(, K = 2 , ,
, . .). ,
.
String64. ( String63) K (0 < K < 10).
.
String65. ( String63) C.
K .
String66. -. ,
, , ,
, , (,
).
String67. , , String66. .
String68. , .
, 0;
,
.
String69. , . ( -

79

), 0.
, , , , 1.
String70 . , : (), [], {}. (
), 0. ,
, ,
, 1.


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

( ,
). ,
1, Pascal
K- F Seek(F, K 1).
, , 2 (
). ,
, , .

80

. . . Programming Taskbook 4.6

File1. S. S ,
TRUE. S
, FALSE.
File2 . N (> 1).
N
(2, 4, . . .).
File3. A D. 10
A D:
A, A + D, A + 2D, A + 3D, . . . .
File4. .
, .
File5. . , . ,
1.
File6. K , .
K- ( 1).
, 1.
File7. , . , , .
File8. . ,
,
.
( ).
File9. . ,
( ) ,
.
(
).
File10 . . , , , .
File11. . ,

81

(1, 3, . . .), (2, 4, . . .).


File12. . ,
, (
). ,
.
File13. . ,
( ), ( ). ,
.
File14. .
.
File15. .
.
File16. . ( ). , 1, 5, 5, 5, 4, 4, 5
4.
File17. . ,
( , ). , 1, 5,
5, 5, 4, 4, 5 :
1, 3, 2, 1.
File18. . ( ,
).
File19. . ( ,
).
File20. . , (
File18 File19).
File21. . ,

82

. . . Programming Taskbook 4.6

( File19).
File22. . ,
( File20).
File23. . ,
. , 1.7, 4.5, 3.4, 2.2,
8.5, 1.2 :
3, 2.
File24. . ,
. , 1.7, 4.5, 3.4, 2.2,
8.5, 1.2 : 2,
3, 2, 2.

File25 . .
.
File26. .
.
File27 . A1 , A2 , . . ., AN (N
).
:
A1 , AN , A2 , AN 1 , A3 , . . . .
File28. . , ,
.
File29. , 50 .
50 ,
.
File30. , .
.
File31. , 50 .
50 ,
.

83

File32. , .
.
File33. . .
File34. . .
File35. , 50 .
50 ,
.
File36. . ,
( ).
File37. . ,
( ).
File38. . .
File39. . , 510.
File40. .
.
File41 . .
.

File42. . .
File43 . . .
File44. , .
.
File45. , .
.
File46. S 0 , N ( 4) N
S 1 , . . ., S N . (
) S 0 .
File47. .
, .

84

. . . Programming Taskbook 4.6

. -
File48 . S A , S B ,
S C S D . S D ,
:
A1 , B1 , C 1 , A2 , B2 , C 2 , . . . .
File49. S A , S B , S C ,
S D S E . S E ,
(
File48).
.
File50 . S 1 S 2 , .
S 3 ,
.
File51. S 1 , S 2 S 3 ,
.
S 4 ,
.
File52. S 0 , N ( 4) N
S 1 , . . ., S N . - S 0 ,
: -
N, N ( )
, .
File53. S, N (> 0) - , ,
File52. - N
S. - N ,
.
File54. S - ,
( ) ,
File52. , ,
( ) ( ) S.
File55. S 0 , N ( 4) N
S 1 , . . ., S N . - S 0 ,

85

: ( ) ,
, . . ., N-
.
File56. S, N (> 0) - , ,
File55. - N
S. - N ,
.
File57. S 1 , S 2 - ,
, File55.
S 1 S 2
, ,
( ).
C
, . Borland Delphi file of ShortString;
,
- .
File58 . ,
. , , .
File59. , . , , .
File60. , . ,
, .
File61 . ,
. , , .
File62. .
.

86

. . . Programming Taskbook 4.6

File63 . K (> 0) . :
, K
, , K- (
K, ,
).
File64. . ,
( ).
File65. . ,
( ).
File66. . ,
,
, .
File67 . , //,
,
(, 16/04/2001). , ,
( ).
File68. , , File67. ,
, ( ).
File69. , , File67. ,
( ).
, .
File70. , , File67. ,
( ).
,
.
File71. , , File67. , .
,
.
File72. , , File67. , .

87

,
.
File73. , , File67. ,
.

M N , M N . (. Matrix).
, ().
,
, .
. .
A M N. B A, N M :
BI,J = AJ,I ,

I = 1, . . ., N, J = 1, . . . M.

A M N, B N P. C A B ( AB),
M P :
C I,J = AI,1 B1,J + AI,2 B2,J + . . . + A1,N BN,J ,

I = 1, . . ., M,

J = 1, . . . P.

A , , , (
. Matrix80):
AI,J = 0,

I > J.

A , , , :
AI,J = 0,

I < J.

88

. . . Programming Taskbook 4.6

A ,
, ,
:
AI,J = 0,

|I J | > 1.

File74 . I, J ,
( ). ,
I- J - (
1). , 0.
File75. , ( ). , ,
.
File76. S A S B ,
A B ( ).
S C , AB. A B
, S C .
File77. I, J ,
( ),
. , I- J - ( 1). , 0.
File78. ,
( ), . , , .
File79. S A S B , A B ( ),

. S C , AB. A B ,
S C .
File80. , ( ). ,
( ).

89

File81. , ( ). ,
( ).
File82. , ( ). ,
( ).
File83. I, J ,
( ). , I- J -
( 1). , 0; ,
1.
File84. I, J ,
( ). , I- J -
( 1). , 0; ,
1.
File85. I, J ,
( ). , I- J -
( 1). , 0; ,
1.
File86. , ( ). ,
( ).
File87. , ( ). ,
( ).
File88. , ( ). ,
( ).
File89. S A S B , A B ( ).
S C , -

90

. . . Programming Taskbook 4.6

AB ( ). A B ,
S C .
File90. S A S B , A B ( ).
S C , AB ( ). A B ,
S C .


,
( ).
.

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


Text1 . N K. N ,
K * ().
Text2. N (0 < N < 27).
N :
( ) a,

91

ab, abc . .;
N .
Text3. N (0 < N < 27).
N N;
K (K = 1, . . ., N) K
( ) , *
(). , N = 4 A***,
AB**, ABC*, ABCD.
Text4 . . ( EOLN EOF
).
Text5. S . S .
Text6. . .
Text7. S . S .
Text8. . .
Text9. K .
K. ,
.
Text10. K .
K. ,
.
Text11. . .
Text12. S .
S.
Text13. . .
Text14. . .
Text15. K .
K. ,
.
Text16 . . .
Text17. .
.
, .
Text18. K .

92

. . . Programming Taskbook 4.6

K ( K,
).
Text19. .
, .
Text20. .
.
Text21 . , .
.
Text22. K (0 < K < 10) ,
K . K .
Text23. K (0 < K < 10) ,
K . , K
.

Text24 . . ,
.
Text25. K . K (
). ,
, . , .
Text26. . , 5 ( ).
.
Text27. K .
K ( .
Text26). .
, .
Text28. .
(. Text26), . (
).
Text29. . .
, / .

93

Text30. .
. , / .
Text31. K . K .
, ,
, / . K,
.
Text32. C ()
.
, ( ).
, ,
, / . , .
Text33. C ()
. , C ( ). , ,
, / . ,
.
Text34 . , ,
. , ( 50).
Text35. , , .
,
( 50).
.
Text36. , ,
. , . .
Text37. , , .

94

. . . Programming Taskbook 4.6

.
( , ),
( )
, (
50).
Text38 . K (> 25) , ,
.
. ,
K , ,
. . .
Text39. K (> 25) , , .
(5 ), .
, K ,
, .
.
.


, ,
, .
Text40. .
, ,
30 (
, ).
| ( 124). .
Text41. .
, ,
20 (
).
| ( 124).

95

.
Text42 . A, B N.

, x [A, B]
(B A)/N. : x

(10 , 4 ) x (15 ,
8 ). .
Text43. A, B N.
, sin(x) cos(x) [A, B] (B A)/N. : x (8 , 4 )
sin(x) cos(x) ( 12 , 8 ).
.
Text44 . , ,
.
.
Text45. ,
,
( ). .
Text46. ,
, (
). , ( ) , .
Text47. ,
,
( ). .
Text48. ,
, (
). ,
( ).
Text49. .

. , .

96

. . . Programming Taskbook 4.6

Text50. . 30
, .
: , ,
, (
).
Text51. , .
, -
. ,
( ).
Text52. ,
. ,
-. ,
- . ,
.

Text53. . ,
, ( ).
Text54. . , , , (
). .
Text55. . , , , (
). .
Text56. . , , , (
). .
Text57 . .
( ) ,
<>< > (, 25). , , .
.

97

Text58. .
( ) ,
<>< > (, 25). , , .
, .
Text59. S, 10 , . , ,
K- , , S K - ( K = 11
S 1 . .). ,
.
Text60. , ,
Text59.
. . , .



. . ,
( ); ,
.

(
,
-), .
, , ,
1 10. , 1

98

. . . Programming Taskbook 4.6

10. , 1.
, , .
Param1 . MinElem(A, N) , A N.
A, B, C N A ,
N B , N C .
Param2. MaxNum(A, N) ,
A N.
A, B, C
N A , N B , N C .
Param3. MinmaxNum(A, N, NMin, NMax), A
N. : NMin ( ) NMax ( ).
A, B, C N A , N B , N C .
Param4. Invert(A, N), A N ( ). A . A, B, C N A , N B , N C .
Param5. Smooth1(A, N), A N : AK K A. A .
A
N, .
Param6. Smooth2(A, N), A N : A1 , AK (K = 2, . . ., N)
AK1 AK . A .
A N, .

99

Param7. Smooth3(A, N), A N :


(
). A
. A N, .
Param8. RemoveX(A, N, X ), A N , X. A
N .
X A , X B , X C A, B, C N A ,
N B , N C .
Param9. RemoveForInc(A, N), A N ,
:
, , ,
, , . .
, 5.5, 2.5, 4.6, 7.2, 5.8, 9.4
5.5, 7.2, 9.4. A N . A,
B, C N A , N B , N C
.
Param10. DoubleX(A, N, X ), A N , X. A
N .
X A , X B , X C A, B, C
N A , N B , N C .
Param11. SortArray(A, N),
A N. A
. A, B, C N A , N B , N C .
Param12. SortIndex(A, N, I), A N I

100

. . . Programming Taskbook 4.6

, A ,
A ( A
). I .
A, B, C N A , N B , N C .
Param13. Hill(A, N), A N :
, ,
, . . ( ). A
. A, B, C N A , N B , N C .
Param14. Split1(A, N A , B, N B , C, N C ),
A N A B
C N B N C ; B
A (1, 3, . . .),
C A (2, 4, . . .).
B C N B N C .
A N A
B C.
Param15. Split2(A, N A , B, N B , C, N C ),
A N A B C
N B N C ; B
A, C ( ).
B C N B N C .
A N A
B C.
Param16. ArrayToMatrRow(A, K, M, N, B), A K B M N
( A ). ; ,
0. B .
A K M N
B M N.

101

Param17 . ArrayToMatrCol(A, K, M, N, B), A K B M N


( A ). ; ,
0. B .
A K M N
B M N.
Param18. Chessboard(M, N, A),
M N A M N, 0 1, , A1,1 = 0.
A .
M N
A M N.
Param19. Norm1(A, M, N) , A M N:
Norm1(A, M, N) = max {|A1,J | + |A2,J | + . . . + |AM,J |},
J 1 N. A
M N Norm1(A, K, N), K = 1, . . ., M.
Param20. Norm2(A, M, N) , A M N:
Norm2(A, M, N) = max {|AI,1 | + |AI,2 | + . . . + |AI,N |},
I 1 M. A
M N Norm2(A, K, N), K = 1, . . ., M.
Param21. SumRow(A, M, N, K) , A M N,
K- ( K > M, 0). A M N K
SumRow(A, M, N, K).
Param22. SumCol(A, M, N, K) , A M N,
K- ( K > N, 0). A M N K
SumCol(A, M, N, K).
Param23. SwapRow(A, M, N, K 1 , K 2 ),
A M N

102

. . . Programming Taskbook 4.6

K 1 K 2 . A ;
K 1 K 2 M, .
, A M N
K 1 K 2 .
Param24. SwapCol(A, M, N, K 1 , K 2 ),
A M N
K 1 K 2 . A ; K 1 K 2 N, .
, A M N
K 1 K 2 .
Param25. Transp(A, M),
( ) A M. A
. , A M.
Param26. RemoveRows(A, M, N, K 1 , K 2 ),
A M N K 1 K 2
(, 1 < K 1 K 2 ). K 1 > M,
; K 2 > M,
K 1 M. A M, N
. RemoveRows,
A M N K 1 K 2
.
Param27. RemoveCols(A, M, N, K 1 , K 2 ),
A M N K 1
K 2 (, 1 < K 1 K 2 ). K 1 > N,
; K 2 > N,
K 1 N. A M, N
. RemoveCols,
A M N K 1
K 2 .
Param28. RemoveRowCol(A, M, N, K, L),
A M N ,
AK,L (, M > 1 N > 1; K > M
L > N, ). A M, N
. A

103

M N K, L. A RemoveRowCol
.
Param29. SortCols(A, M, N), A M N
( : , , ; ,
. .). A . SortCols,
A M N.

Param30 . IsIdent(S) , ,
S , ,
, . S , 0. S ,
1, S , 2.
S , . IsIdent
.
Param31. FillStr(S, N) , N, S ( - ). ,
N -
N.
Param32. UpCaseRus(S),
S ( S
). S . UpCaseRus, .
Param33. LowCaseRus(S), S ( S
). S .
LowCaseRus, .

104

. . . Programming Taskbook 4.6

Param34. TrimLeftC(S, C), S , C. S


. C .
TrimLeftC, .
Param35. TrimRightC(S, C), S , C. S
. C .
TrimRightC, .
Param36. InvertStr(S, K, N) , S,
N S, ee K- . K S, ;
K + N, , ee K-
. InvertStr S : (K 1 , N 1 ), (K 2 , N 2 ), (K 3 , N 3 ).
Param37. PosSub(S 0 , S, K, N) ,
, S S 0 , N S,
K- ( , PosSub
). K S, 0,
K + N, ,
K- . S S 0 , 0.
PosSub S 0 , S : (K 1 , N 1 ), (K 2 , N 2 ), (K 3 , N 3 ).
Param38. PosLast(S 0 , S) ,
, S
S 0 . , S 0
S . S S 0 ,
0.
S 0 S.
Param39. PosK(S 0 , S, K) ,
, S K- S 0 (K > 0). S 0 S K,
0. , S 0 S .

105

: S 0 , S K.
Param40 . WordK(S, K) ,
K- S ( ,
/ ). K,
. , S
K 1 , K 2 , K 3 .
Param41. SplitStr(S, W, N),
S W , S ( W N ). ,
/
; , S 10 . SplitStr, N,
S, .
Param42. CompressStr(S) ,
S : S,
C, {K}, K C (,
S { }). ,
S = bbbccccce bbbc{5}e.
CompressStr .
Param43. DecompressStr(S) , , CompressStr (. Param42).
S ;
. DecompressStr
.
Param44. DecToBin(N) ,
N
. 01
( 0).
,
.
Param45. DecToHex(N) ,
N 16-
. 09,
AF (

106

. . . Programming Taskbook 4.6

0). , 16-
.
Param46. BinToDec(S) ,
S
. S ,
01 ( 0).
, , .
Param47. HexToDec(S) ,
S 16-
. S , 09, AF (
0). , ,
16- .

Param48. IntFileSize(S) , S. , 1.
.
Param49 . LineCount(S) , S. ,
1.
.
Param50. InvertIntFile(S),
S .
,
.
.
Param51. AddLineNumbers(S, N, K, L),
S
: N, N + 1 .
. K ,
L (K > 0, L > 0).
, , . ,

107

N, K L.
Param52. RemoveLineNumbers(S), S , AddLineNumbers (.
Param51), , .
,
. .
Param53 . SplitIntFile(S 0 , K, S 1 , S 2 ), K ( 0) S 0
S 1 , a S 2 .
. S 0 ,
K, S 1 S 2 .
Param54. SplitText(S 0 , K, S 1 , S 2 ), K
( 0) S 0 S 1 , a
S 2 . . S 0 ,
K, S 1 S 2 .
Param55. StringFileToText(S),
S .
, S 1
S 2 .
Param56. TextToStringFile(S),
S .
, S 1
S 2 .
Param57. EncodeText(S, K),
S,
, K-
(0 < K < 10). , K = 3
, . , ,
. , ,
.
K, .
Param58. DecodeText(S, K),

108

. . . Programming Taskbook 4.6

S, K
( Param57).
K, .

Param59Param63
, , .
Param64Param70 (x-),
(y-).
Param59 . TDate Day (),
Month () Year () LeapYear(D)
TDate, TRUE, D
, FALSE .
LeapYear (,
). , 4,
, 100 400.
Param60 . TDate LeapYear (. Param59),
DaysInMonth(D) TDate,
, D.
DaysInMonth (, ).
Param61 . TDate DaysInMonth (. Param59
Param60), CheckDate(D) TDate, , D.
D , 0;
, 1;
, 2.
CheckDate .
Param62. TDate DaysInMonth CheckDate (.
Param59Param61), PrevDate(D)
TDate, D ( D
, ). D
. PrevDate
.

109

Param63. TDate DaysInMonth CheckDate (.


Param59Param61), NextDate(D)
TDate, D ( D
, ). D
. NextDate
.
Param64. TPoint X Y
( ) Leng(A, B)
, AB
:
q
|AB| = (A.X B.X )2 + (A.Y B.Y )2
(A B TPoint).
AB, AC, AD, A, B, C, D.
Param65. TPoint Leng (. Param64), TTriangle A, B, C TPoint (
) Perim(T) ,
T (T TTriangle).
ABC, ABD, ACD, A, B, C, D.
Param66. TPoint, TTriangle Leng Perim (.
Param64 Param65), Area(T)
, T (T TTriangle)
:

S ABC = p(p |AB|)(p |AC|)(p |BC|),


p . ABC, ABD, ACD, A, B, C, D.
Param67. TPoint, TTriangle Leng Area (. Param64Param66), Dist(P, A, B)
(P, A, B TPoint), D(P, AB)
P AB
D(P, AB) = 2S P AB /|AB|,
S P AB PAB.
P AB, AC, BC,
P, A, B, C.
Param68. TPoint, TTriangle Dist (.
Param64, Param65, Param67), Heights(T, h1 , h2 , h3 ),

110

. . . Programming Taskbook 4.6

h1 , h2 , h3 T (T
TTriangle, h1 , h2 , h3 ), T.A, T.B, T.C.
ABC, ABD, ACD, A, B, C, D.
Param69. TPoint Leng (. Param64), PerimN(P, N) ,
N-, ( ) P N (> 2) TPoint. ,
.
Param70. TPoint, TTriangle Area (.
Param64Param66), AreaN(P, N) ,
N-, ( ) P N (> 2)
TPoint. , .


. ,
, .
, (., ,
Recur4 Recur6).
.
Recur1 . Fact(N) ,
N! = 12. . .N
(N > 0 ).
.
Recur2. Fact2(N) ,

111

N!! = N(N2)(N4). . .
(N > 0 ;
2, N , 1, N ).
.
Recur3. PowerN(X, N) ,
N- X :
X 0 = 1,
X N = (X N/2 )2 N > 0,
X N = X X N 1 N > 0,
X N = 1/X N N < 0
(X 6= 0 , N ; N ).
X N X N.
Recur4 . Fib1(N) ,
N- (N ):
F 1 = F 2 = 1,
F K = F K2 + F K1 , K = 3, 4, . . . .
,
Fib1, .
Recur5 . Fib2(N) ,
N- (N ):
F 1 = F 2 = 1,
F K = F K2 + F K1 , K = 3, 4, . . . .
, N 20. Fib1 (. Recur4)

Fib2. Fib2 .
Recur6. Combin1(N, K) , C(N, K) N K
:
C(N, 0) = C(N, N) = 1,
C(N, K) = C(N 1, K) + C(N 1, K 1) 0 < K < N.
; N > 0, 0 K N. N
K. C(N, K) Combin1,
.

112

. . . Programming Taskbook 4.6

Recur7. Combin2(N, K) , C(N, K) N K


:
C(N, 0) = C(N, N) = 1,
C(N, K) = C(N 1, K) + C(N 1, K 1) 0 < K < N.
; N > 0, 0 K N. ,
N 20.
Combin1 (. Recur6)
C(N, K) Combin2.
Combin2 C(N, K) N
K.
Recur8. RootK(X, K, N) ,
K- X
:
Y 0 = 1,
Y N +1 = Y N (Y N X /(Y N )K1 )/K,
Y N RootK(X, K, N) X K. : X (> 0) , K (> 1) N (> 0) .
RootK X
K- N.
Recur9. NOD(A, B) ,
() A
B, :
(A, B) = (B, A mod B), B 6= 0;
(A, 0) = A.
(A, B), (A, C), (A, D),
A, B, C, D.
Recur10 . DigitSum(K) ,
K, .
.
Recur11. MaxElem(A, N) , A N
(1 N 10), .
A, B, C N A , N B , N C
.
Recur12. DigitCount(S) ,
S, .

113


.
Recur13. Palindrom(S) , TRUE, S (
), FALSE .
. Palindrom .

, ,
, .
.
Recur14 . ,
S. :
<> ::= <> | <> + <> |
<> <>

Recur15 . ,
S. :
<> ::= <> | <> + <> |
<> <>
<>
::= <> | <> * <>

Recur16 . ,
S. :
<> ::= <> | <> + <> |
<> <>
<>
::= <> | <> * <>
<>
::= <> | (<>)

Recur17 . ,
S. :
<> ::= <> |
(<><><>)
<>
::= + | | *

Recur18 . ,
S ( ,

114

. . . Programming Taskbook 4.6

Recur17). , TRUE,
FALSE.
Recur19. ,
S ( , Recur17). , 0,
, S.
Recur20. ,
S. ( M , m ):
<> ::= <> | M(<> , <>) |
m(<> , <>)

Recur21 . , S. (T TRUE, F
FALSE):
<> ::= T | F | And(<> , <>) |
Or(<> , <>)
Recur22. ,
S. ( M , m ):
<> ::= <> | M(<>) | m(<>)
<> ::= <> | <> , <>
Recur23. , S. (T TRUE, F
FALSE):
<> ::= T | F | And(<>) | Or(<>)
<> ::= <> | <> , <>
Recur24. , S. (T TRUE, F
FALSE):
<> ::= T | F | And(<>) |
Or(<>) | Not(<>)
<> ::= <> | <> , <>

115


Recur25 . N,
K (< 10) ( 1 K).
0.
, . ,
(
).
Recur26. N, K (< 10) ( 1 K).
0.
, :
. , Recur25.
Recur27 . N (N ),
2 : A 1 B 1.
C 0.
, :
0.
, Recur25.
Recur28. N , Recur27.
,
:
.
, Recur25.
Recur29. N,
3 : A 1, B 0 C 1.
D 0. , :
, 0.
, Recur25.
Recur30. N , Recur29. ,
: , 0. ,

116

. . . Programming Taskbook 4.6

Recur25.


Dynamic, Pascal C++.
, , .
PNode TNode.
PNode TNode Pascal
:
type
PNode = ^TNode;
TNode = record
Data: integer;
Next: PNode;
Prev: PNode;
end;
++:
struct TNode
{
int Data;
TNode* Next;
TNode* Prev;
};
typedef TNode* PNode;
Dynamic1Dynamic2,
(Dynamic3Dynamic28) TNode Data Next (. Dynamic1);
(Dynamic29Dynamic80) TNode (.
Dynamic29).
, ( )
( ) .

117

, , , 1.
nil ( Pascal).
Dynamic1. P1 TNode, Data (
) Next ( PNode TNode).
Next .
Data , P2 .
Dynamic2 . P1 TNode. Next
, , , , , Next nil ( ,
). Data
, ( )
.

Dynamic3Dynamic13 (stack)
- TNode (. Dynamic2).
Next nil. (top)
.
( nil). Data.
Dynamic3 . D P1 . D P2
.
Dynamic4. N (> 0) N . , ( ),
.
Dynamic5 . P1 .
() D, P2
.
, P2 = nil. , .
Dynamic6. P1 , .

118

. . . Programming Taskbook 4.6

. .
, .
Dynamic7. P1 ( , P1 = nil).
. N ( 0).
, .
Dynamic8 . P1 P2 . (
,
) . .
Dynamic9 . P1 P2 . ,
(
, ). ,
.
( ,
nil).
.
Dynamic10 . P1 . ,
, (
, ;
). ( nil).
.
Dynamic11 . P1 ( , P1 = nil).
N (> 0) N . TStack
Top PNode ( )
Push(S, D), S
D (S TStack, D
). Push
(
) .

119

Dynamic12 . P1 ,
. TStack (. Dynamic11), Pop(S) , S ()
, ,
(S TStack).
Pop . (
,
nil).
Dynamic13. P1 . TStack (.
Dynamic11), StackIsEmpty(S)
( TRUE, S , FALSE ) Peek(S)
( S,
). S TStack. , Pop
Dynamic12, (
, ) . StackIsEmpty
, ,
.

Dynamic14Dynamic28 (queue) - TNode (. Dynamic2).


Next nil. (, head) , (, tail)
.
, ,
.
nil. ,
Data.
Dynamic14. 10 . ,
(
, ), P1 P2
.

120

. . . Programming Taskbook 4.6

Dynamic15. 10 . : (1, 3, . . ., 9),


(2, 4, . . ., 10); .
, .
Dynamic16. 10 . : ,
(
). ,
( ;
nil).
Dynamic17. D P1 P2
( , P1 = P2 = nil).
D
.
Dynamic18. D P1 P2 ,
. D
() .
.
,
.
Dynamic19. N (> 0) P1 P2 . N
( N ,
). (
nil). , .
Dynamic20. P1 P2 . ,
, (
,
). (
nil). , .
Dynamic21. ; P1 P2 ,
P3 P4 ( ,

121

nil). (
)
.
.
Dynamic22. N (> 0) ;
P1 P2 , P3 P4 . N .
N ,
. ,
( nil).
.
Dynamic23. ; P1 P2 , P3 P4 .
, ( ,
). , (
nil). .
Dynamic24. ; P1 P2 , P3 P4 .
. , ( ).
.
.
Dynamic25 . ; P1 P2 , P3 P4 .
( ).
. .
, Data .
Dynamic26. P1 P2 (
, P1 = P2 = nil). N (> 0)
N . TQueue Head Tail
PNode ( )
Enqueue(Q, D), Q

122

. . . Programming Taskbook 4.6

D (Q TQueue, D ). Enqueue

.
Dynamic27. P1 P2 ,
. TQueue (. Dynamic26),
Dequeue(Q) ,
() , , (Q TQueue). Dequeue
.
(
, nil).
Dynamic28. P1 P2 .
TQueue (. Dynamic26), QueueIsEmpty(Q)
, TRUE, Q , FALSE
(Q TQueue).
, Dequeue
Dynamic27, ( , )
. QueueIsEmpty
.

Dynamic29. P2 TNode, Data (
) Prev Next ( PNode TNode).
Prev Next . Data
, P1 P3
.
Dynamic30 . P1 -
TNode, Next. Prev TNode, ()
,
( Next), (
Prev). Prev nil. -

123

.
Dynamic31Dynamic69 (doubly
linked list) - TNode,
, (. Dynamic30).
Next Prev
nil.
,
: (first),
(last) (current).
nil. ,
Data.
Dynamic31. P0
. N , P1 P2 .
Dynamic32. D1 D2 P0 .
D1 , D2 .
.
Dynamic33. D P0 .
D .
Dynamic34. D P0 .
D .
Dynamic35. P1 P2 , .
(
) .
Dynamic36. P1 P2 , .
(
)
.

124

. . . Programming Taskbook 4.6

Dynamic37. P1 . (
)
.
Dynamic38. P1 . (
)
.
Dynamic39. P1 . (
)
.
Dynamic40. P1 . (
) .
Dynamic41. P0 . :
, , ,
( ; nil).
, .
Dynamic42. P1 , .
. , .
Dynamic43. P1 .
(
, nil). , .

125

Dynamic44. P0
. .
, Data .
Dynamic45. P0
. .
, Data .
Dynamic46. K (> 0) P0
. K
( K , ).
.
, Data .
Dynamic47. K (> 0) P0
. K
( K , ).
.
, Data .
Dynamic48. PX PY ( PX
PY , ).
. ,
Data .
Dynamic49 . P1 . , ( )
. , Data .
Dynamic50. P1 . , ( )

126

. . . Programming Taskbook 4.6

. , Data .
Dynamic51. : P1 P2
, P0 . ,
( )
,
.
.
Dynamic52. : P1 P2
, P0 . ,
( )
,
.
.
Dynamic53. PX PY ; PX
PY , . , ( ),
( ). .
, nil.
.
Dynamic54. PX PY ; PX
PY , . , ( ),
( ). .
, nil.
.
Dynamic55 . P1 . , Next
, Prev . ,

127

.
Dynamic56. P1 P2 , . (. Dynamic55), ,
. P3 P4
( P3 , P4 ).
.
Dynamic57. K (> 0) P1 P2
.
K (
)
.
(. Dynamic55),
, K. .
Dynamic58. K (> 0) P1 P2
.
K (
) . (. Dynamic55),
, K.
.
Dynamic59 . P1 , P2 P3 , ( ,
P1 = P2 = P3 = nil). N (> 0) N .
TList First, Last Current PNode ( , )
InsertLast(L, D), D L (L TList,
D ).
. ( )
, .

128

. . . Programming Taskbook 4.6

Dynamic60. P1 , P2 P3 , ( ,
P1 = P2 = P3 = nil). N (> 0) N . TList (. Dynamic59), InsertFirst(L, D),
D L (L
TList, D ). .
( )
, .
Dynamic61. , , P1 , P2 P3 .
. TList (. Dynamic59), InsertBefore(L, D), D
L (L
TList, D ).
.
,
.
Dynamic62. , , P1 , P2 P3 . . TList (. Dynamic59),
InsertAfter(L, D), D L (L
TList, D ). .
,
.
Dynamic63 . , ,
P1 , P2 P3 . TList (. Dynamic59), ToFirst(L) (
L), ToNext(L) ( L , ), SetData(L, D) (
L D ) IsLast(L)
( TRUE, L , FALSE ). L TList;

129

ToFirst ToNext .
, ,
.
Dynamic64. , , P1 , P2 P3 . TList
(. Dynamic59), ToLast(L) (
L), ToPrev(L) ( L , ) GetData(L)
( L), IsFirst(L) ( TRUE, L
, FALSE ). L
TList; ToLast ToPrev .
, .
.
Dynamic65. P1 , P2 P3 , , . TList (. Dynamic59),
DeleteCurrent(L) , L
(L
TList).
, , .
, .

. ,
( nil).
Dynamic66. P1 , P2 P3 ,
. TList (. Dynamic59), SplitList(L1 , L2 ),
L1 L2 (
, L1 , ). TList;
, . -

130

. . . Programming Taskbook 4.6

.
.
,
.
Dynamic67. ,
. TList (.
Dynamic59), AddList(L1 , L2 ),
L1 ( ) L2 ;
L1 . L2
.
TList . .

, .
Dynamic68. ,
. TList (.
Dynamic59), InsertList(L1 , L2 ),
L1 ( ) L2
; L1 . L2 . TList .
.
, .
Dynamic69. ,
( ).
TList (. Dynamic59), MoveCurrent(L1 , L2 ),
L1 L2 (
L2 ; L1 ,
, ).
TList . .

131

,
.

Dynamic31Dynamic69 , ,
. ,
, . Next
Prev , , ,
, (, Prev
Next ). , , : Barrier,
, Current, (
, ). Data ;
0.
, .
Dynamic70Dynamic80 .
Dynamic70 . P1 P2 , ,
( , P1 = P2 = nil). (. Dynamic55),
.
0 Next Prev ( Next Prev
). .
.
Dynamic71. P1 P2 ( . Dynamic70).

132

. . . Programming Taskbook 4.6

, .
,
( ).
.
.
Dynamic72. P1 P2
( . Dynamic70). ,
( ).
( , ).
.
Dynamic73. P1 P2
( . Dynamic70). ,
( ).
( , ).
.
Dynamic74 . P1 P2 ( . Dynamic70).
N (> 0) N . TListB
Barrier Current PNode (
) LBInsertLast(L, D),
D L (L
TListB, D
). . (
) .
Dynamic75. P1 P2 -

133

. N (> 0) N . TListB (. Dynamic74),


LBInsertFirst(L, D), D
L (L TListB, D ). .

(
) .
Dynamic76. P1 P2 . . TListB (. Dynamic74), LBInsertBefore(L, D), D L (L
TListB, D ). .

.
Dynamic77. P1 P2 . . TListB (. Dynamic74), LBInsertAfter(L, D),
D L (L
TListB, D
). .
.
Dynamic78 . P1 P2 . TListB (. Dynamic74),
LBToFirst(L) ( L), LBToNext(L) ( L ),
LBSetData(L, D) ( L D
, )
IsBarrier(L) ( TRUE,
L , FALSE ). L TListB; LBToFirst LBToNext
.

, -

134

. . . Programming Taskbook 4.6

.
;
.
Dynamic79. P1 P2 . TListB (. Dynamic74),
LBToLast(L) ( L),
LBToPrev(L) ( L ) LBGetData(L) ( L). L TListB; LBToLast
LBToPrev . , IsBarrier
Dynamic78, ,
.
. .
Dynamic80. P1 P2 , . TListB (. Dynamic74), LBDeleteCurrent(L) , L
(L TListB). ,
, .
, .
, 0. ,
IsBarrier Dynamic78,
( , )
. .

(.NET)
Dynamic, .NET: C# Visual Basic
.NET.
, , .
Node.

(.NET)

135

Programming Taskbook (, pt4net.dll, PT4) :


:
public Node();
public Node(int aData);
public Node(int aData, Node aNext);
public Node(int aData, Node aNext, Node aPrev);
( ):
public int Data;
public Node Next;
public Node Prev;
, , :
public void Dispose();
Dynamic1Dynamic2,
(Dynamic3Dynamic28) Node Prev (. Dynamic1); (Dynamic29Dynamic80) Node
(. Dynamic29).
.NET ,

, ,
, Node, (
Put PT, pt4net.dll).
, , , 1.

null ( C#).
Dynamic1. A1 Node, Data
Next Node. Next
A2 ( Node). Data
, A2 .
Dynamic2 . A1 Node.
Next Node, , , , Next, null (-

136

. . . Programming Taskbook 4.6

, ).
Data , (
) .

Dynamic3Dynamic13 (stack) - Node (. Dynamic2).


Next null. (top)
. Node ( null).
Data.
Dynamic3 . D A1 .
D A2 .
Dynamic4. N (> 0) N . , ( ),
.
Dynamic5 . A1 . () D, A2
. ,
A2 = null.
, , Dispose.
Dynamic6. A1 , .
. .
, ,
Dispose.
Dynamic7. A1 ( , A1 = null).
.
N ( 0). , ,
Dispose.
Dynamic8 . A1 A2 .
(
, )

(.NET)

137

.
Node .
Dynamic9 . A1 A2 . ,
( , ).
,
. ( ,
null). Node .
Dynamic10 . A1 . ,

, (
, ; ).
( null). Node
.
Dynamic11 . A1 ( , A1 = null).
N (> 0) N . IntStack,
:
top Node ( );
aTop ;
Push(D), D (D );
Put ( ), top,
Put PT.
Push ( )
, Put IntStack.
Dynamic12 . A1 , .
IntStack (. Dynamic11) Pop ( ), ()
, Dispose.
Pop . (
, -

138

. . . Programming Taskbook 4.6

null).
Dynamic13. A1 . IntStack (.
Dynamic11) : IsEmpty ( TRUE,
, FALSE ) Peek ( , ).
. , Pop
Dynamic12, (
, )
. IsEmpty , ,
.

Dynamic14Dynamic28 (queue) - Node (. Dynamic2).


Next null. (, head) , (, tail)
.
, ,
. null. ,
Data.
Dynamic14. 10 . ,
(
, ), A1 A2
.
Dynamic15. 10 . : (1, 3, . . ., 9),
(2, 4, . . ., 10);
.
, .
Dynamic16. 10 . : ,
(
). ,

(.NET)

139

( ;
null).
Dynamic17. D A1 A2 (
, A1 = A2 = null). D
.
Dynamic18. D A1 A2 , . D
() . ,
.
Dispose.
Dynamic19. N (> 0) A1 A2 . N
( N ,
).
( null).
Dispose.
Dynamic20. A1 A2 . ,
, ( ,
).
( null).
Dispose.
Dynamic21. ; A1 A2 ,
A3 A4 ( ,
null). (
)
. Node
.
Dynamic22. N (> 0) ;
A1 A2 , A3 A4 . N
.
N , . ,

140

. . . Programming Taskbook 4.6

( null).
Node .
Dynamic23. ; A1
A2 , A3 A4 .
,
( ,
).
, (
null). Node .
Dynamic24. ; A1 A2 ,
A3 A4 . .
, ( ).
. Node
.
Dynamic25 . ; A1
A2 , A3 A4 .
( ). .
. Node
, Data .
Dynamic26. A1 A2 (
, A1 = A2 = null). N (> 0)
N . IntQueue, :
head tail Node ( );
aHead, aTail ;
Enqueue(D), D (D );
Put ( ), head
tail, Put PT.
Enqueue
,
Put IntQueue.
Dynamic27. A1 A2 , . IntQueue (.

(.NET)

141

Dynamic26) Dequeue ( ), () ,
Dispose. Dequeue
.
(
, null).
Dynamic28. A1 A2 .
IntQueue (. Dynamic26) IsEmpty
( ), TRUE, , FALSE
.
, Dequeue Dynamic27,
(
, ) .
IsEmpty
.

Dynamic29. A2 Node, Data , Prev Next Node.
Prev A2 ,
Next .
Data , A1 A3
.
Dynamic30 . A1 -
Node, Next. Prev , () ,
( Next), ( Prev). Prev
null. A2 .
Dynamic31Dynamic69 (doubly
linked list) - Node,
, (. Dynamic30).
Next Prev

142

. . . Programming Taskbook 4.6

null.
,
: (first),
(last) (current). null. ,
Data.
Dynamic31. A0 . N , A1
A2 .
Dynamic32. D1 D2 A0
. D1 , D2 .
.
Dynamic33. D A0 .
D .
Dynamic34. D A0 .
D .
Dynamic35. A1 A2 , .
(
)
.
Dynamic36. A1 A2 , .
(
)
.
Dynamic37. A1 . (
)
.
Dynamic38. A1 . (
)

(.NET)

143

.
Dynamic39. A1 . (
)
.
Dynamic40. A1 . (
)
.
Dynamic41. A0 . : ,
, ,
( ;
null).
Dispose.
Dynamic42. A1 , . .
Dispose.
Dynamic43. A1 .

(
, null).
Dispose.
Dynamic44. A0 .
.
Node , Data .
Dynamic45. A0 .
.
Node , Data .
Dynamic46. K (> 0) A0
. K
( K ,
). -

144

. . . Programming Taskbook 4.6

. Node
, Data .
Dynamic47. K (> 0) A0
. K
( K ,
). . Node
, Data .
Dynamic48. AX AY
( AX AY , ).
.
Node , Data .
Dynamic49 . A1 . ,
( )
. Node ,
Data .
Dynamic50. A1 . , ( )
. Node ,
Data .
Dynamic51. : A1 A2 , A0 . , ( ) ,
.
Node .
Dynamic52. : A1 A2 , A0
. ,
( ) ,
. Node .
Dynamic53. AX AY -

(.NET)

145

; AX AY ,
. ,
( ), (
).
. , null. Node
.
Dynamic54. AX AY ; AX AY ,
. ,
( ), (
).
. ,
null. Node .
Dynamic55 . A1 . , Next
, Prev
. ,
.
Dynamic56. A1 A2
, . (. Dynamic55),
, . A3 A4
( A3 , A4 ). Node .
Dynamic57. K (> 0) A1 A2
.
K ( )
.
(. Dynamic55),
, K. Node .
Dynamic58. K (> 0) A1 A2
.

146

. . . Programming Taskbook 4.6

K (
)
.
(. Dynamic55),
, K.
Node .
Dynamic59 . A1 , A2 A3 , ( ,
A1 = A2 = A3 = null). N (> 0) N .
IntList, :
first, last, current Node (,
);
aFirst, aLast, aCurrent , ;
InsertLast(D), D (D ,
);
Put ( ), first,
last current, Put PT.
InsertLast
( ) ,
, Put
IntList.
Dynamic60. A1 , A2 A3 , ( ,
A1 = A2 = A3 = null). N (> 0) N .
IntList (. Dynamic59) InsertFirst(D),
D (D
). . InsertFirst
(
) ,
.
Dynamic61. A1 , A2 A3 , . .
IntList (. Dynamic59) InsertBefore(D),

(.NET)

147

D (D ).
. InsertBefore
,
.
Dynamic62. A1 , A2 A3 , . .
IntList (. Dynamic59) InsertAfter(D),
D (D ).
. InsertAfter
,
.
Dynamic63 . A1 , A2 A3 , . IntList (. Dynamic59) ToFirst (
), ToNext ( ,
), SetData(D) ( D ), IsLast (
TRUE, ,
FALSE ). ToFirst, ToNext IsLast
; D SetData
.
, ,
.
Dynamic64. A1 , A2 A3 , . IntList (.
Dynamic59) ToLast ( ), ToPrev ( , ) GetData (
), IsFirst ( TRUE, , FALSE
). .
,
. .

148

. . . Programming Taskbook 4.6

Dynamic65. A1 , A2 A3 , , .
IntList (. Dynamic59) DeleteCurrent
( ), .
, , . DeleteCurrent Dispose. DeleteCurrent
. ,
( null).
Dynamic66. A1 , A2 A3 , . IntList (.
Dynamic59) Split(L1 , L2 ), L1 L2
( , L1 , ). IntList;
, . .
Node Split .

,
( null).
Dynamic67. ,
. IntList (.
Dynamic59) Add(L1 , L2 ), L1 ( ) L2 ;
L1 . .
IntList .
Node Add .
,
.
Dynamic68. ,
. IntList (.
Dynamic59) Insert(L1 , L2 ), -

(.NET)

149

L1 ( ) L2
; L1 .
L2 .
IntList .
Node Insert .
, .
Dynamic69. ,
( ).
IntList (. Dynamic59)
MoveCurrent(L1 , L2 ), L1
L2 ( L2
; L1 , , ).
IntList .
Node MoveCurrent .

,
( null).

Dynamic31Dynamic69 ,
null, .
,
, . Next Prev , , ,
, (,
Prev Next ). ,
, : Barrier,
, Current, (
, ). Data ;

150

. . . Programming Taskbook 4.6

0.
, .
Dynamic70Dynamic80 .
Dynamic70 . A1 A2 , ,
null ( , A1 = A2 = null). (. Dynamic55),
.
0 Next Prev (
Next Prev ).
. Node, .
Dynamic71. A1 A2 ( . Dynamic70).
, .
,
( ). .
Node,
.
Dynamic72. A1 A2
( . Dynamic70). ,
(
). ( ,
).
Dispose.
Dynamic73. A1 A2
( . Dynamic70). ,
(

(.NET)

151

). ( ,
).
Dispose.
Dynamic74 . A1 A2 ( . Dynamic70).
N (> 0) N . IntListB,
:
barrier current Node ( );
aBarrier aCurrent ;
InsertLast(D), D (D ,
);
Put ( ),
current, Put PT.
InsertLast
( )
, Put IntListB.
Dynamic75. A1 A2 . N (> 0) N .
IntListB (. Dynamic74) InsertFirst(D),
D (D ). .
InsertFirst
(
) .
Dynamic76. A1 A2 . . IntListB (.
Dynamic74) InsertBefore(D),
D (D ). .
InsertBefore
.
Dynamic77. A1 A2 -

152

. . . Programming Taskbook 4.6

. . IntListB (.
Dynamic74) InsertAfter(D),
D (D
). . InsertAfter
.
Dynamic78 . A1 A2 . IntListB (. Dynamic74) ToFirst ( ), ToNext (
), SetData(D) ( D ,
) IsBarrier (
TRUE, ,
FALSE ). ToFirst, ToNext IsBarrier
. D SetData
.
, .
;
.
Dynamic79. A1 A2 . IntListB (. Dynamic74) ToLast ( ), ToPrev (
) GetData
( L).
. ,
IsBarrier Dynamic78,
, . .
.
Dynamic80. A1 A2 , . IntListB (. Dynamic74)
DeleteCurrent , . ,
, -

153

. Dispose.
, 0. ,
IsBarrier Dynamic78,
( , ) .
.

1. . . 1000 . I:
, , .
, 2004. 43 .
2. . . 1000 . II:
, , , . , 2004. 42 .
3. . . 1000 . III:
, , , . , 2004. 43 .
4. . ., . .
: , ,
. 2- . --: , 2005. 198 .
5. . . : , , , , . 5- ., . --: , 2006. 187 .
6. . . C# VB
.NET. --: , 2006. 220 .

154

. . . Programming Taskbook 4.6


. . . . . . . . . . . . . . . . . . . .
C++ . . . . . . . . . . . . . . . . . . . . . .
Visual Basic . . . . . . . . . . . . . . . . . .
.NET (C# VB.NET) . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

7
8
9
9
10

11

14

17

20

22


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

25
29

29

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

32
34


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

36
36
38
42

46


. . . . . . . . . .

49
49

155

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


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

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

()

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

.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.


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

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

51
54
55
55
57
59
60
61

.
.
.
.

63
63
65
68
70

. . . . . . .

72
72

. . . . . . .

73

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

74
76
77

.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.


. . . . . . . . . .
, . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . .
. -
C . . . . . . . . . . . . . . . . .
. . . . . . .

.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.
.
.
.

79
80
80
82
83
84
85
87


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

90
90
92
94

.
.
.
.
.
.
.

. . .

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

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

96
97
97
103
106
108

110
. . . . . . . . . . . . . . . . 110
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
. . . . . . . . . . . . . . . . . . . . . . . . . . 115

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

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

(.NET)
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . .

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.

116
117
119
122
131

.
.
.
.

134
136
138
141
149
153

Оценить