Professional Documents
Culture Documents
.
, .
. 14 , .
( 1-5) ,
.
.
. . . .
,
.
, , .
.
( ). , . , , . ,
.
iv
, , , .
:
1. ...........................................................................1
1.1 .........................................................................3
1.2 ..............................................................5
1.3 ........................................................................8
1.4 ..............................................................11
1.5 ...........................................................16
1.6 ..........................................................18
2. ................................................................23
2.1 ........................................................................25
2.2 ..........................................................27
2.3 ................................28
2.4 / .............................28
2.4.1 .............................................................30
2.4.2 .................................................................32
2.4.3 ..................................35
2.4.4 .............................................37
2.4.5 ..........................................................39
3. ........................................................51
3.1 .......................................................................................53
3.2 + = ........................54
3.3 .........................................................................................56
3.4 ...........................................................................................59
3.5 .............................................................................................60
3.6 ....................................................................................64
3.7 ...................................................................................66
3.8 ......................................................................................69
vi
3.8.1 .....................................69
3.8.2 .....................70
3.8.3 Fibonacci...................72
3.9 .................................................................73
3.9.1 .................................................................................73
3.9.2 ................................................................................75
3.9.3 ................................................................................75
4. ...........................................................79
4.1 ................................................................81
4.2 ...................................................83
4.3 .......................................................85
4.4 ......................................................87
4.5 .........................................................................90
5. ............................................................................95
5.1 ....................................................................97
5.1.1 ..........................97
5.1.2 ..................................98
5.1.3 ........99
5.1.4 .........................................100
5.2 ...............................................................101
5.3 .....................................................104
5.3.1 ...................................107
5.3.2 .....................................................108
5.4 .........................................................................109
6. .......................................................115
6. 1 .....................................................117
6.2 .....................................................................117
6.2.1 ...........................................................118
6.2.2 .....118
6.2.3 ............................................119
6.2.4 4 .........................................................127
6.3 . ..................................................130
6.4 ...........................................131
6.4.1 ..............................132
6.4.2 ......................................132
6.4.3 .......................................132
6.5 ....................................136
6.6 .................................................137
6.7 .............................................137
7. ...................................................145
7.1 ........................................................148
7.2 ........................................................................148
7.3 .....................................................................................149
7.4 ................................................................................151
7.5 ..................................................................152
7.6 ................................................................................153
7.7 ...............................................................153
7.8 ......................................................................154
7.9 - .............................................................155
7.10 ................................................................157
8. ......................................................................163
8.1 ........................................................................165
8.1.1 .........................................................................166
vii
viii
8.1.2 .............................................................172
8.2 ..................................................................173
8.2.1 ...............................................173
8.2.2 _ ...................................................175
8.2.3 ....................................................178
9. .................................................................................................183
9.1. . ...........................................................185
9.2. ..............................191
9.3. .............................................................191
9.4. .................................................198
10. ..............................................................................203
10.1. ................................................205
10.2. ...............................207
10.3. ..............208
10.4. .............................................................................209
10.5. ...................................................210
10.5.1 ..................................213
10.5.2 ....................................214
10.5.3 ..........................216
10.6. -. ...........................................220
10.7. .................................................................................222
11. ..................................229
11.1. .................................231
11.1.1 ....................................................................232
11.1.2 ...........................................................................234
11.1.3 ........................................................................235
11.1.4 .........................................................................237
11.2. .....................238
11.2.1 ...................................................................239
11.2.2 .............................................240
11.3.
...............................................241
11.4. ........248
11.4.1 ............................................................249
11.4.2 ..........................................................251
11.5. .............................................252
12. ..............................................................259
12.1. ......................................................................261
12.2. ..........................................................262
12.3. ..........................................266
12.4. ..................................270
12.4.1 .......................................................................271
12.4.2 ........................................................273
12.5. .................................274
13. .......................................................279
13.1 ....................................................................281
13.2 .........................................................................284
13.3. ......................................................284
13.4 ..............................288
14. - .................................................................291
14.1 .....................................293
14.1.1 - .................................................293
14.1.2 ..........................................................................297
ix
14.1.3 ......................................................................301
14.1.4 .......................................................................305
14.2 ...............................................308
14.2.1 ........................................................310
14.2.2 ...............................................310
14.2.3 .............................................315
14.3 ..........................................................315
: ASCII....................................................................323
............................................................................326
................................................................................................327
.............................................................................................333
.................................................................................................337
1.
, .
, , , , .
, ,
, .
:
3
;
3 2000";
3 ;
3 ,
;
1.1
,
. ,
,
. , ,
, , . ,
.
: , , ,
.
, ,
, .
, .
. ,
.
,
.
, ,
.
Robin Wood
Nottingham.
,
.
2000
(millennium bug).
. , 15 1999 150499.
,
, . 21
010100,
.
2000 . ()
. .
, , , , - ,
2000.
, . 2000
.
, ,
.
, ,
,
, Pasteur Fleming, .
.
-
,
, , , .
,
,
.
, , ,
,
, , .
, ,
,
, .
, .
, , , , , , .
1.2
. ,
.
-
.
.
, , , .
,
, , , .
. , .
.
. . ,
, .
. , ,
. .
.
1
,
. , .
, :
. . .
,
. , .
, . , ,
.
. . .
.
. ,
, . - - .
: .
: .
. , ( ) ( ).
.
. . .
:
.
.
, .
. ,
.
1.3
.
.
, .
.
: , .
. ,
.
2
.
.
, :
(1)
(2)
(3)
.
.
(1) ,
:
(1.1)
(1.2) ,
(1.3)
(2) , :
(2.1)
(2.2)
(2.3)
(3) ,
:
(3.1)
(3.2)
(1.1) :
(1.1.1)
(1.1.2)
(1.1.3)
10
(1.2),
:
(1.2.1)
(1.2.2)
(1.2.3)
, .
.
, , .
. . :
,
,
. , .
1.1.
. 1.1.
. ,
.
1.4
. .
. .
. , . , .
11
12
. .
, , .. , .
3
, . , .
: .
, .
:
, , ,
. .
.
.
;
.
, ;
.
, .
.
13
1.1.
: 9
:
: 2
:
/
10
17
15
. 100 , .
.
1.1.
,
. ,
. .
:
100 ;
, ,
.
, ,
.
.
:
, ;
.
92 8.
, , .., 5809 , 5287
522 . -
14
. , ,
. , .
.
,
10 13 ..
, . , 1.2.
1.2.
1999-2000.
522
9,0
10
13
1211
20,8
14
15
2120
36,5
16
17
1180
20,3
18
20
776
13,4
5809
100
1.2 , ( ) ( ).
, .
, 1.2,
, . 1000 .
. 1.2. .
,
.
, .
,
.
, .
. , , , . ,
( ),
.
15
16
( 1.3):
,
,
, ,
.
. 1.3.
1.5
, ,
. ,
. .
1.
,
:
,
. , , .
,
, ,
.
, .
,
, . . , .
2.
17
, :
, . , ,
.
,
,
.
. , ,
.
, . . ,
.
.
3.
,
. , :
,
,
.
.
:
, .
, -
,
,
.
18
, .
.
:
.
,
. .
:
.
1.6
, .
. , ,
. ,
.
,
, ,
, ;
.
.
.
.
, .
, , -
. .
, , .
.
. ,
, . ,
. ,
,
.
, .
,
3 .
3 ,
3 ,
3 ,
3 .
,
:
3 , ,
,
3 , ,
3 , .
,
.
19
20
.
.
.
.
,
,
.
.
.
. , .
.
.
, .
, , , , , , .
21
-
.
.
.
, , .
1.4.
.
;
.
1.
2.
3.
4.
5.
6.
22
http://snow.utoronto.ca/Learn2/targets8.htm
,
. , ,
, .
.
http://www.awesomelibrary.org/Classroom/Science/Problem_Solving/Pro
blem_Solving.html
. , .
http://www.suremath.com/suremath/suremath/essential.html
. ,
.
http://www2.hawaii.edu/suremath/click.html
,
, ,
(, , ) .
http://www.infinn.com/creative.html
, , .
2.
24
. ,
.
,
, .
, . , , . , , , , . , . ,
,
.
:
,
,
,
,
.
3 ;
3 ;
3 ,
;
3 3+6+9++999;
2.1
,
1 n.
. ,
. 25 , .
(algorithm)
Abu Jafar Mohammed ibn Musa al Khowarizmi,
825 ..
Algoritmi dixit ... ( ....). al Khowarizmi
( al-jabr=), . , .
20
.
, ,
. , .
: ,
,
.
.
(input). ,
. , -
25
26
.
(output).
.
(definiteness).
. ,
, .
(finiteness). . , (computational
procedure).
(effectiveness). .
, .
. , ,
:
3 ,
3 ,
3 ,
3 ,
3 ,
3 ,
3 ,
3 .
. ,
, , , ,
. , , -
,
(
) .
2.2
. ,
, ,
.
H , ,
:
(hardware). ,
(
, .).
(programming languages).
(, ) . ( assembly C)
( Basic Pascal). ,
. ,
(
).
(theoretical). , .
, . ,
.
(analytical). (computer
resources) , -
27
28
,
CPU / .. 5.
2.3
:
(free text),
. ,
.
(diagramming techniques),
.
,
, (flow chart).
, .
(natural language) .
, , , .
(coding), .
,
.
2.4
, .
,
. :
, ,
,
,
, ,
, .
.
..
29
30
, .
, , , , .
( ),
.
2.4.1
( )
, .
. .
.
1. A
, .
=
=
_1
a
b
c a + b
c
T _1
.
, . . , a
, a
.
31
(constands). .
, .. 123, +5, -1,25
.. ,
,
(variables). ,
. , . , , .
(operators). . , .
(expressions). (operands), . .
.
.
, ,
.
.
a b : c a + b. . :
, , . , . ,
=
. 2.1.
1
32
. .
, . . , .
a b
, c , . , (),
(), ().
, 2.1.
2.4.2
/ .
.
,
. . , . , , , .
,
.
( )
. . ,
.
33
2.
.
, , , .
, ,
,
. .
+ 5 = 5 5 = 5
_2
a
a < 0 a a*(-1)
a
_2
.... :
: ( ), .
, .
... , , .
, _. .
_1
_2
...............
_
_
,
a . , (), (),
(). 2.1.
34
. 2.2. 2
3.
, , .
_3
a, b
a < b
c a + b
c a * b
_
c
_3
, :
. 2.3. 3
2.4.3
. ,
1 24,
.
.
35
36
4.
, 1 2 3 .
_4
a
a = 1
_ a = 2
_ a = 3
_
_4
. 2.4. 4
,
...
(select case), .
5.
.
_5.
;
age
age<0
...
0 age < 5
!!
5 age < 60
60 age < 100
age > 100
_
_5
2.4.4
.
... , ( )
.... ,
.
6.
. , 80 , . 1.70, .
37
38
_6
,
< 80
< 1.70
,
,
_
< 1.70
,
,
_
_
_5
. 2.5. 6
39
. . . ,
, , . . .
( )
. .
2.4.5
, . , , . ,
. ,
= *
. (
). -
40
.
7.
: ...
1
100.
i i + 1
i
.
, . , .. 5, 207, -32 . 1. , i, 1 100
1.
ii+1
i i 1.
100 i i + 1. ....
:
:
, . ,
_.
:
,
_ .
_7
i 1
i 100
i
i i + 1
_
_7
41
8:
.
:
,
. , , , ,
. :
1.
2.
3. 1.
,
( ). , . , .
, 3 :
3. ,
1, .
. :
,
, .
, .... :
_8
x
x > 0
x
x
_
_8
,
. ,
,
.
42
. ,
, ,
.. 999999. . ...
:
x 999999
9. :
_..._
. , .
_9
_
x
E x
_ x < 0
_9
_..._
,
x .
, .
10.
: ......
100 1
100.
, ....... .
43
_10
Sum 0
i 1 100
Sum Sum + i
_
E Sum
_10
, ......
, i (=1) (=100). i
1, , 1.
Sum , 0, . Sum .
. 2.6. 10
44
11. :
.........
1 100.
.
, i.
_11
0
i 2 100 _ 2
+ i
_
E
_11
....... ,
, .
, .
, , :
k 100 0 _ -1
k 5 5
k 5 1
, . . , f(x) x 0
1,
x 0 1 _ 0,01
12.
,
.
. , ,
. ,
,
, , .. ,
2.7.
, . ,
. ( ), ,
. ,
,
.
, , , 45
19. - , . 2.8 ,
. ,
, . ,
.
(shift)
, 0 1, , ,
.. 17 00010001 ,
byte.
, 0 0,
00100010 , 34
. , , ,
1 0,
00001000 , 8
. , .
45
45
19
405
+ 45
855
x
. 2.7.
.
45
19
45
90
90
180
360
720
720
= 855
. 2.8. .
46
1.
: , +,
,
:
,
: , .
2.
, ,
_ (underscore).
, .
3.
+, -, *, /, ^
: , <, =, , >,
: (), (), ().
4.
, , ,
.
5.
6.
<> <>
<>
<_1>
<_2>
_
1
_1
............
_
_
_
<_1>
<_1>
_ <_2>
<_2>
......
_ <_>
<_>
<_>
_
7.
<>
_ <>
1 2 _
8.
, , , ..
9.
, , , ..
10.
- , !,
!.
11.
<_> <_>
12.
( )
// ... //.
// ... //.
47
48
,
. , ,
.
. , ,
(shift),
. .
.
: ( )
: M1 M2, M1, M2 1
: P=M1*M2
1
2
3
4
5
6
P=0
M2>0, 3, 7
2 , P=P+M1
1=1*2
2=2/2 ( )
2
P.
.
__
// 1,2 //
P 0
M2 > 0
M2 mod 2 = 1 P P+M1
M1 M1*2
M2 [M2/2]
_
// P, 1,2 //
__
. . .
, . , , ,
.
, , , , , , , .
-
1.
2.
3.
4.
5.
6.
/ ;
7.
8.
9.
10.
.
11.
49
50
.
12. .
13.
; ;
1.
., ., .,
, , 1991.
2.
, , , 1993, .
3.
,
Pascal, Art of Text, , 1998.
4.
.. , , , 1990.
5.
6.
7.
http://hissa.ncsl.nist.gov/~black/CRCDict/
, (Algorithms, Data Structures, and Problems Terms and Definitions
for the CRC Dictionary of Computer Science, Engineering and Technology)
http://www.ee.uwa.edu.au/~plsd210/ds/ds_ToC.html
, .
3.
52
, . .
, , .
, , , .
:
,
,
,
,
,
.
3 FIFO;
3 , ;
3 ;
3 , ;
3.1
53
(data) . ,
.
, , , , .,
, . , , ,
.
(information). ,
.
. , , , . ,
,
, (Information Theory),
.
,
. , :
. (hardware), ,
(representations). , SCII (.
), EBCDIC, 1 2 ..
.
(high level programming languages) (types) (variables)
. , ,
.
. (data structure)
.
, (record),
, .
(fields) (attributes) , , . -
(byte)
11110001.
H :
l
_ ASCII 437
928
1 EBCDIC
241
( )
-14
( 1)
-15
( 2)
2 4
bytes, .
, ,
, ,
,
.
54
. .
.
. (Databases), (Data Modelling) (Knowledge Representation)
.
3.2
+ =
,
.
, . (data structure)
.
:
.
(nodes). ( ) :
3 (access),
.
3 (insertion), .
3 (deletion), , .
3 (searching),
, .
3 (sorting),
.
3 (copying),
.
3 (merging), .
3 (separation),
.
.
,
,
, .
, .
. ,
. ,
.
1976 Wirth
( Pascal)
+ =
.
.
.
: (1,1), (2,2), ...,
(n,n), i i i- , i=1,2,...,n.
: k k.
,
.
55
56
.
: , . (,n1),
(B,n2), ..., (,n24). K ni ( i=1, 2, ..., 24) .
: .
:
(static) (dynamic).
(dynamic memory allocation). , ,
.
. ,
3.3
,
.
.
,
. ( , .).
. ,
(indexes) .
, -
57
, -
.
, (square) n x n.
, . ,
.
1.
table 100 .
_
// table //
Min table[1]
i 2 100
table[i] < Min Min table[i]
_
//Min//
_
Min. , Min , . Min table.
2.
table m n . , .
. , .
.
. 3.1
(, , )
58
_
// m, n, table //
sum 0
i 1 m
row[i] 0
_
j 1 n
col[j] 0
_
i 1 m
j 1 n
sum sum + table[i,j]
row[i] row[i] + table[i,j]
col[j] col[j] + table[i,j]
_
_
// row, col, sum //
_
, , .
, ,
. , i 1 j 1,2,,n. , i 2, j
1,2,,n. i m.
5x5. ,
row
, col . sum - .
59
row
table
col
16
21
53
28
38
13
51
139
17
67
22
40
30
176
20
40
10
13
86
21
34
48
29
26
158
90
166
123
106
127
612
Sum
, (stack) (queue), , .
3.4
. , (top)
, . ,
,
. , LIFO
. 3.2. .
60
(Last-In-First-Out). ,
.
:
(push) ,
(pop) .
,
, (overflow) . , , , (underflow) .
. 3.3
, 3.3. ( top)
.
() top
. ()
top top
.
3.5
. , , , , .. .
, ,
(Operations Research), (Queueing Theory), . , ( ). , FIFO (First-In-First-Out).
:
(enqueue) ,
(dequeue) .
, ,
: (front) (rear) ,
.
3.4 (), () .
. 3.4. .
, 3.5.
rear . ,
front,
, .
, , .
. 3.5
61
62
FIFO LIFO
LIF,
FIFO.
.
. , , . , , .. , .
.
.
, ,
;
o .
, .
(.. ),
. FIFO
.
, . .
1/1/99
100
400
15/1/99
120
10
720
1120
63
30/1/99
200
1000
.
/
1/1/99
15/1/99
30/1/99
400
10
720
400
1120
. , .
) LIFO
30/1/99 5
6 , 120 .
=5x120 = 600 . =1120-600=520. 1000-600=400.
) FIFO
30/1/99 5 , 4 1/1/99 1 15/1/99.
=4x100+1x120=520 =1120-520=600. ,
1000-520=480.
)
, .
1120/10=112. =5x112=560
=1120-560=560.
1000-560=440 .
64
3.6
(searching)
.
, . ,
. .
(sequential) (linear) .
Sequential Search key table. position 0, , , (, 1 n).
Sequential_Search
// n, table, key //
done
position 0
i 1
(done=) (i<=n)
table[i]=key
done
position i
i i+1
_
_
//done, position //
Sequential_Search
, table
. , . ,
: done
i n. , , , .
,
. , 56 4 . , () 11 9 , .
. 11 12.
, . , :
3 ,
3 ( , n 20),
3 ,
. 3.6.
65
66
, .
3.7
(sorting)
(ordering). (ascending
sequence) .
.
,
, , , .
.
. a1,a2,...,an
(permutation) , ak1,ak2,...,akn ,
(ordering function), f, :
f(ak1) f(ak2) ... f(akn)
A
, (descending sequence) .
H (straight exchange sort)
, .
.
- -
(bubbles) ,
-
/ , .
, . (files).
, , . ,
,
,
, . (records),
(fields),
, . ,
: , , , , .
(primary key) . (secondary keys), .
(searching)
, ( , , , ..), ( , , , , ..),
(,
.).
. (bubblesort).
. : 52, 12, 71, 56, 5, 10, 19, 90 45.
.
,
-
67
68
.
(i).
. 3.7. .
.
.
(quicksort).
.
// table, n //
i 2 n
j n i _ 1
table[j-1] > table[j]
table[j-1], table[j]
_
_
_
// table //
table n . , , ,
.
table[j-1], table[j]
. .
temp table[j-1]
table[j-1] table[j]
table[j] temp
3.8
(recursion), .
.
,
, .
3.8.1
H . , n, n , n!,
:
n! = 1 x 2 x 3 x x (n-1) x n
n ( n 1) ! n > 0
n!=
n = 0
1
.
. n .
// n //
n = 0
product 1
product n * (n-1)
_
// product //
69
70
, n! , 2.
2
// n //
product 1
i 2 n
product product * i
_
// product //
2
, n , . , .
3.8.2
E
() .
.
.
x y.
( ), . , z,
z
, x y,
z.
__
// x,y //
x < y
z x
z y
_
(x mod z 0) (y mod z 0)
z z-1
_
// z //
__
71
,
,
.
// x,y //
z y
z 0
z x mod y
x y
y z
_
// x //
35
150
35
10
35
10
10
, . H
.
// x,y //
y = 0
z x
z (y, x mod y)
_
// z //
72
3.8.3
Fibonacci
, ,
Fibonacci , :
0
Fi = 1
F = F + F
i1
i2
i
i = 0
i = 1
i > 1
Fibonacci :
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 .
A . Fibonacci
Fn .
n.
Fibonacci1
// n //
n 1 Fib n
f0 0
f1 1
i 2 n
fib f0+f1
f0 f1
f1 fib
_
// Fib //
Fibonacci1
Fibonacci2
// n //
n 1
Fib n
73
. ,
. .
. . ,
,
.
Fibonacci
,
,
. , .
F5. Fibonacci .
3.9
. , . ,
.
3.9.1
. (pointer) . , .., , . , 3.8. -
. 3.8
74
index pointer
. ,
.
3.9 ,
, .
. 3.9.
. 3.10
.
. 3.10.
,
(dynamic),
,
.
,
,
.
, ()
( ). ,
.
. 3.11.
, 3.11. (
) , .
3.9.2
(trees) , . , ( ). ,
, . , , . 3.12.
. . ,
... ,
.
. 3.12.
3.9.3
(graph) (
) ( ) . ,
.
. 3.13.
75
76
. . , ,
, .
, , .
.
( ),
, . ,
.
.
.
/
.
. ,
, .
, , , ,
, , , FIFO LIFO, , , , , , .
-
1.
;
.
2.
3.
4.
5.
6.
7.
8.
9.
10. .
11. ;
12. .
13. .
14. .
15. .
16. .
17. .
1.
, , , 1996.
2.
, .
, , 1993.
77
78
3.
,
Pascal, Art of Text, , 1998.
4.
, , , 1993.
5.
6.
7.
http://hissa.ncsl.nist.gov/~black/CRCDict/
, (Algorithms, Data Structures, and Problems Terms and Definitions
for the CRC Dictionary of Computer Science, Engineering and Technology).
http://www.ee.uwa.edu.au/~plsd210/ds/ds_ToC.html
, .
4.
80
, ,
. ,
,
. ,
.
.
:
,
,
,
,
.
3 ;
3 ;
3 ;
4.1
, . . ,
, . ,
. .
:
3 ,
3 ,
3
:
3 ,
3 .
, :
1.
2.
3.
4.
5.
,
,
( ),
(.. ),
(.. )
. , , , , . ,
.
81
82
. 4.1. .
4 4
, 6
. ,
. ,
1, , 2, 3 4. .
)
1.
2.
3.
36 .
1.
2.
30 .
, ,
,
. ,
. ,
. , :
,
( ),
, .
4.2
, , .
, -
83
84
. , .
. ,
.
( ). , :
3 ,
3
3 .
.
, .
. ,
:
3
3
3
.
, . .
,
.
4.3
85
2.
-
.
3.
-.
4.
-, .
: .
, n .
. n : names[1..n] phones[1..n] .
, ,
(
).
, 3 :
1.
names,
. 4.2.
86
2.
names,
3.
names.
. (, names).
, .
_
// names, phones, onoma, arxi, telos //
meso [arhi + telos]/2
onoma = names[meso]
Tel phones[meso]
. .
.
. 4.3 -
.
, , .
. ,
,
. , , - . , .
. ( Bolzano)
f(x)=0 [a, b]. , ,
f(a).f(b)<0 ( ). x1 (=(a+b)/2)
[a, b] , f(a).f(x1)<0. ,
[a, x1], [x1, b]. x2 .
x1, x2, ...
. , .
. 4.4
4.4
, .
- -
87
88
. , (bottom up). ,
. ,
, .
..
.
, .
,
- . :
1.
2.
3.
. ,
,
.
, , , ab. 1, .
89
1
// a, b //
power 1
i 1 b
power power * a
_
// power //
1
1
, , b
b- . , a16
: (((2) 2)2)2.
,
b. power
. , 2 (, a=2),
0 1, 1 2, 2 4,
3 16 , .
0
0
1
1
2
2
3
4
4
8
2 =1
2 =2
2 =4
2 =16
2 =256
0-
. 4.5 2.
, , . , 27 , 4 2, 27 = 24 *22 *21.
ab
, .
90
2
// a, b //
!:
power[1] a
i 1
pow 1
pow < b
i i+1
pow 2* pow
power[i] power[i-1] * power[i-1]
_
!:
used 0
result 1
used < b
used + pow <= b
result result * power[i]
used used + pow
_
pow pow / 2
i i - 1
_
// result //
2
4.5
,
, ,
, . ,
, . . ,
4.1, . (greedy method),
:
( ).
,
, .
1,
2, 5, 10, 20, 50 100 200, 500, 1000,
5000 10000 .
, , . 789 . 1 , 1 , 1 , 1 , 1 , 1 2 , 8 .
,
. T
,
.
// C, n, poso //
find poso
coins 0
choice n
(choice>0) (find > 0)
C[choice]<= find
coins coins + 1
find find - C[choice]
choice choice - 1
_
_
// coins //
91
92
C n .
( coins). , .
. . : , . .
. . ,
, .
, , ,
, .
-
1.
2.
3.
4.
5.
6.
7.
, .
8.
1.
:
, , , 1993.
2.
: .
, , 1993.
3.
: , , , 1988.
4.
:
Pascal, Art of Text, , 1998.
5.
, , , , 1996.
6.
, , , 1995.
7.
Niklaus Wirth: , , ,
1990.
8.
9.
93
94
http://www.cs.pitt.edu/~kirk/algorithmcourses/index.html
. .
http://www.wisdom.weizmann.ac.il/~naor/puzzler.html
puzzle.
/.
http://www.cs.sunysb.edu/~algorith/
(Stony Brook)
- . .
5.
96
.
, (, ). , ,
() . , ,
, .
:
,
,
,
,
,
.
3
;
3 ;
5.1
,
.
(performance)
(efficiency) .
. :
1.
2.
3.
, ;
.
.
5.1.1
, . .
.
. , :
3 ,
3 ,
3 .
, , .
97
98
: :
1
n 10
A_
m
n n - 1
M_ (m=0) (n=0)
m
1
10 ( n=0).
5.1.2
(size) .
. ,
. ,
,
n,
.
5.1
,
:
. 5.1.
(n)
5.1.3
99
:
2
x 123
y 234
i 0 4
i
z x * y
_
x
y
z
2
. 5 , :
x y
i
i
i
i
z (25)
1
6
5
5
10
x, y, z
32
n ,
n. 5.2
n, - :
100
. 5.2.
5.1.4
42 -
10
77 -
100
707 -
1.000.000
7 ()
, . ,
,
, . , , . , . ,
:
,
,
,
-,
, .
,
, :
3 ,
3 ,
3 ,
3
.
5.2
,
.
.
.
. , ,
. , .
. ,
, , .. .
. ,
;
, . :
: 10 .
:
101
102
3
// a //
low a[1]
i 2
i < 10
a[i] < low low a[i]
i i+1
_
// low //
3
, . 10 , . 3 :
11
56
32
69
81
90
222
444
65
51
51
99
98
90
11
333
38
224
61
73
80
59
,
. :
6
3, 2. , , .
,
.
, , , .
(i < 10), .
103
,
. , , ,
.
, , .
1/10, 10 . 0,9.
, 0,9*0,9=0,81.
:
0,1
0,9
0,19
0,81
0,271
0,729
0,344
0,656
0,410
0,590
0,469
0,531
0,522
0,478
, 7 0,5 .
. ,
.
.
:
104
,
, . .
a b
. , .
, : a b b a, .
,
a0 b0 . ,
: a=b0 b=a0.
. , ,
. :
t a, a b b t
, ,
.
5.3
(empirical) (a posteriori).
, , (processing time) (memory space). .
.
,
.
.
(theoretical) (a priori).
n, (size)
,
, . , .
, k n=k.
f(n) (time complexity) (space complexity).
, .
O (-notation),
order . .
: f(n),
O(g(n)), c n0,
n n0 :
f ( n) c g ( n)
.
f(n)=2n3+5n2-4n+3. , x (
) ,
. , 2 g(n)=n3. ,
(n3). ,
.
f(n)=5.2n+4n2-4logn, g(n)=2n, f(n) 5
2n. ,
f(n), 1, 2, 3 n .
( , n=10),
2n.
-
105
106
, ,
. , ,
.
, :
(1). K
. .
(logn). . log , ln
. , .
O(n). .
n .
O(n logn). (n logn),
( ).
.
O(n2). .
.
O(n3). . .
O(2n). .
5.3 (n). . (n3) , (23) . ,
.
107
. 5.3.
n=20
n=40
n=60
(n)
0.00002
0.00004
0.00006
(n2)
0.0004
0.0016
0.0036
0.008
0.064
216
(2 )
1.0 o
2.7
366
(n!)
771
3 1032
3 1066
(n )
.
, ,
.
3, .
5.3.1
C, (key
comparisons), .
(moves) . C M n ,
.
,
,
. :
C = 1 + 2 + + (n-1)
C=
n ( n 1)
2
,
(n2).
108
5.3.2
3.6 ,
.
,
(successful). , (unsuccessful).
.
, .
, n . , , , . , n-
, n
. ,
:
=
(1 + 2 + K + n)
n
n ( n + 1)
2n
n +1
2
, (n),
.
(n). ,
,
.
, ,
.
. 5.4.
(1)
(1)
Fibonacci
(n)
O(n2)
O(n)
O(logn)
5.4
109
, ,
, . , ,
. , .
.
, / . ,
, , ,
( ).
, . ,
, , . (parallel) ,
, , . ,
.
,
2 ,
, . . , .
110
,
.
, . , ,
, ,
,
..
, , (Computational Complexity),
. , . (optimal),
, .
(polynomial)
. ,
(n), O(n3/2), O(n2) ..
O(2n), O(n2 2n) O(nn), .
, .
, :
x1, x2, , xn (
n ). n/2 , ,
x1, x2, , xn (
n ). n/2 , .
, . , n ,
. (n2), . ,
-
. , .
. (2n).
( ) , . (intractable).
,
.
.
. ,
,
. ,
.
, , NP- Nondeterministic
Polynomial.
.
,
(approximate) ,
.
, ,
.
, , ,
, .
. -
111
112
,
.
,
.
,
.
. () .
.
, (, , ).
/ , , , , , , , ,
, ,
-
1.
2.
3.
113
4.
5.
6.
7.
8.
9.
10. , .
11. ;
12. ;
13. ;
1.
,
, , ,
1993.
2.
, .
, , 1993.
3.
, , , , 1988.
4.
,
Pascal, Art of Text, , 1998.
5.
. , , , , 1993.
6.
Niklaus Wirth, , , ,
1990.
7.
8.
114
9.
http://www.csd.auth.gr/~contest/
. .
http://olympiads.win.tue.nl/ioi/
.
http://acm.baylor.edu/acmicpc/
Association for
Computing Machinery (ACM).
6.
116
. , . . ,
,
. ,
.
.
:
.
.
.
.
3
;
3 ;
3 ;
3 ;
3 ;
6. 1
117
, , .
.
.
.
,
,
. ,
, , .
.
, .
. ,
, ,
,
.
,
. ,
, .
6.2
. ,
.
(hardware) , , -
()
()
118
1945 , .
,
,
.
6.2.1
,
.
, 0
1, .
,
.
ENIAC ,
, ,
.
,
. ,
, .
0 1, ,
, .
6.2.2
, ,
0 1. ADD () , . . ,
(assembler).
,
, -
119
.
.
, .
, . ,
.
10101000
10001100
00111100
01010001
01000011
11000000
10001100
11111111
00001010
00000001
00000001
00000001
11111010
00000010
LOOP
INDEX=$01
SUM=$02
LDA #10
STA INDEX
CLA
ADD INDEX
DEC INDEX
BNE LOOP
STA SUM
BRK
sum = 0
FOR index=1 TO 10
sum=sum+index
NEXT index
END
. 6.1. ,
1 10
6.2.3
-,
50
.
1957 IBM
FORTRAN. FORTRAN FORmula
TRANslation, . FORTRAN
. FORTRAN ,
, .
FORTRAN ,
. FORTRAN , .
120
PROGRAM EQUATION
READ(*,1) A,B
1 FORMAT(F5.1)
IF (A.EQ.0) GO TO 20
X=(-1.)*B/A
WRITE(*,2) X
2 FORMAT(X=,F10.2)
GO TO 50
20 IF (B.EQ.0) WRITE(*,3)
IF (B.NE.0) WRITE(*,4)
3 FORMAT()
4 FORMAT()
50 STOP
END
.6.2. FORTRAN . , .
4, 77, 90/95 Visual
FORTRAN. .
FORTRAN ,
,
.
.
1960 , COBOL. COBOL (Cmmon Business Oriented Language - ) , , FORTRAN .
COBOL .
.
, ALGOL (ALGOrithmic Language ). ,
121
IDENTIFICATION DIVISION.
PROGRAM-ID. EQUATION.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-PC.
OBJECT-COMPUTER. IBM-PC.
SPECIAL-NAMES. DECIMAL-POINT IS COMMA.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 X
PIC S9(6)V9.
77 A
PIC S9(6).
77 B
PIC S9(6).
77 W-X
PIC -(6),-.
PROCEDURE DIVISION.
ARXH.
DISPLAY .
ACCEPT A.
DISPLAY .
ACCEPT B.
DISPLAY .
IF A = 0
GO TO ROYT-1.
COMPUTE X = B * (- 1) / A.
MOVE X TO W-X.
DISPLAY H : W-X.
STOP RUN.
ROYT-1.
IF B = 0
DISPLAY
ELSE
DISPLAY .
STOP RUN.
. 6.3. COBOL Grace Marray Hopper
1960. COBOL
-
. COBOL
(divisions).
, ADD, MULTIPLY, MOVE
.. .
-
.
.
122
10 REM
20 INPUT A=,A
30 INPUT B=,B
40 IF A=0 THEN 100
50 X=-B/A
60 PRINT X=;X
70 END
100 IF B=0 THEN PRINT ELSE PRINT
110 END
. 6.4. BASIC 1964 Dartmouth College
-
Kemeny Kurtz.
. BASIC
(1975).
8 ROM Bill Gates Paul Allen.
,
Microsoft Bill Gates
. GWBASIC 1981 IBM PC. ,
.
QuickBASIC Visual BASIC. .
1960,
.
60 PL/1
(Programming Language/1 1)
, , ,
FORTRAN COBOL .
. 60
LISP (LISt Processor- ), PROLOG
(PROgramming LOGic ) 70.
( , ,
..).
,
60 , BASIC PASCAL.
TO KYBOS :A
REPEAT 4 [FD :A RT 90]
PU SETPOS [20 20] PD
REPEAT 4 [FD :A RT 90]
PU HOME PD
REPEAT 2 [FD :A RT 45 FD 29 RT 135]
PU SETX :A SETY 0 PD
REPEAT 2 [FD :A RT 45 FD 29 RT 135]
HOME
END
. 6.5. LOGO 1967
Seymoyr Papert. -.
-
. -
.
123
124
(DEFUN a-exisosi (a b)
(setf apot (- (/ b a)))
(princ )
(princ a)
(princ x + )
(princ b)
(princ = 0 = )
(princ apot))
. 6.6. LISP 1959 .
-
.
, ,
-
. , -
. ..
(a-exisosi 2 5).
.
.
C. C
BELL
Unix, , Pascal . C C++, . 70 .
.
, (Internet), JAVA. H JAVA
SUN
, ,
.
,
.
-
#include <stdio.h>
int main(int argc, char* argv[])
{
float a, b;
printf(A = );
scanf(%f, &a);
printf(B = );
scanf(%f, &b);
if (a == 0) {
if (b == 0) {
printf(\n);
}
else {
printf(\n);
}
}
else {
printf(X = %f\n, -b/a);
}
return 0;
}
. 6.7. C Bell
-
& 1972 Dennis Ritchie. C
.
UNIX, C
.
.
-. , , .
(object driven programming) (visual
programming).
125
126
CLEAR
? 1.
? 2.
? 3.
? 4.
INPUT [1..4] : TO CHOICE
DO CASE
CASE CHOICE=1
APPEND
CASE CHOICE=2
LABEL FORM PELATES
CASE CHOICE=3
BROWSE
OTHERWISE
QUIT
END CASE
. 6.8. dBASE 70
Ashton-Tate 8-bit . dBASE
() . dBASE ,
. ,
xBASE,
Access.
. , .
Visual Basic, Visual C++
Java.
:
.
.
.
.
.
.
.
,
.
6.2.4 4
( 3 ) . .
, .
. 4 .
,
, -
127
128
.
(procedural) . , . :
(object -oriented languages)
(functional languages) .. LISP
(non procedural languages) ..
PROLOG. .
(query languages) .. SQL.
. :
.
. . :
3 (science-oriented languages) .. FORTRAN
3 (business-oriented languages)
.. COBOL.
.. BASIC, Pascal.
(system programming
languages) .. C.
(artificial intelligence languages) ..
LISP, PROLOG.
. .. , , , , ..
,
.
SELECT ENAME, JOB, SAL
FROM EMPLOYES
WHERE DEPTNO=20
AND SAL > 300000;
SQL
EMPLOYES ,
20 300.000 .
. . .
.
.
.
,
.
,
, . , .
129
130
6.3
, .
, . , , , .
, ,
.
.
: 48 (-
-), 10 (0-9) .
(A-Z a-z)
.
,
. , , .
(accidence)
(syntax).
. , , ,
.
131
.
.
(Semantics)
.
, .
.
. ,
,
,
.
, .
,
. ( GW-Basic QuickBasic)
( Basic Visual Basic).
6.4
,
,
, ,
.
132
6.4.1
(top-down
program design) , ,
, , .
,
.
,
6.4.
6.4.2
. , (module), .
.
,
, .
6.4.3
,
. 6.4.
133
134
GOTO:
GOTO (). GOTO
,
.
.
GOTO,
, .
GOTO.
, ,
,,,,,
>0 GOTO 1
=0 GOTO 2
GOTO 4
1:
GOTO 4
2:
GOTO 4
4:! ,
,,,,
>0
_ =0
_
,,,
GOTO .
,
GOTO .
, .
GOTO .
GOTO .
,
,
, .
, , .
.
.
2 .
GOTO, .
,
.
135
136
.
.
.
.
.
.
.
6.5
70
.
(object-oriented) .
.
. ()
. ,
.
.
,
(objects). ,
137
. , , ;,
;, ;
;. 11.
,
.
6.6
, .
.
. ,
.
,
.
5, ,
.
6.7
,
, .
. -
OCCAM.
138
, (compilers) (interpreters).
. .
.
(source), (object).
, .
,
(libraries) . (linkerloader).
(executable), . .
, . . , .
, .
. 6.5.
.
,
, , , .
.
.
, .
, , . . , ,
. -
. 6.6.
139
140
,
.
.
,
.
(editor). ,
,
: , . .
. (visual)
( , , ) .
. , .
, , .
,
, , . , .
. , -
, .
, ,
.
-
;
;
;
;
;
;
;
;
;
;
;
;
;
;
, , , , , , , , ,
141
142
1.
Ph. Breton, , , ,
2.
. , , , 1986.
3.
. -, , ,
, , 1992.
4.
, , , 1986.
5.
6.
. -. , COBOL ,
, , , 1992.
7.
8.
. -. , GWBASIC ,
, , 1992.
9.
. -. -. , PRO
LOG, , , 1991.
to
Computing
and
Algorithms,
cuiwww.unige.ch/langlist
. 2000 .
www.swcp.com/~dodrill/
.
www.progsource.com
, , Pascal, Delphi, C/C++, Java, Perl, Visual Basic.
www.hensa.ac.uk/parallel/
.
Softwaredesign.com/objects.html
.
Iamwww.unibe.ch/~scg/Ooinfo
,
.
143
7.
146
, ,
. .
.
,
,
.
, ,
.
:
.
.
.
.
, , .
3 ;
3 ;
3 ;
3 ;
,
.
,
. .
:
,
. , .
. ,
. , .
, , .
, . , Pascal,
Visual Basic, C, C++, Java , .
.
,
.
.
147
148
7.1
, , ,
, .
(-)
(-)
(-)
(a-z)
0-9
+ - * / = ^ ( ) . , ! &
7.2
,
.
,
,
.
. . , . 1, 3409, 0, -980.
.
. 3.14159,
149
7.3
(constants) .
, , , .
, (
, ).
-1 = --1
-2 = --2
.
.
.
- = --
(bytes). bytes
.
.
(integer)
1, 2 4 bytes (real) 4 8 bytes.
150
=3.14159
=0.18
=
.
,
.
.
, ( ) , . (-,
-), (0-9) (underscore)
(_), .
, , , , .,
. .
: ,
, , _, 100, , , _.
: 100,
, $.
7.4
(variable) .
=
() , . , .
,
.
, .
.
, , .
,
.
, , ,
.
, , ,
_, .
-1: --1
-2: --2
.
.
.
-: --
151
152
: ,
: ,
:
:
.
, , , ,
.
.
,
.
7.5
: , ,
,
.
:
7.6
153
DIV
div
, mod .
..
MOD
7 div 2 = 3 7 mod 2 = 1
. :
()
()
()
_()
()
()
ex
A_M(X)
_()
7.7
, (expressions). , , ,
.
.
,
.
154
, , .
,
1.
2.
3.
a+1
a+1
1/2 a
. .
1/2*a^3
3x + 2y
ab
(3*x+2*y)/(a-b)
2*()
,
. . .
, . ..
2+3*4 14, (2+3)*4 20,
.
7.8
155
- <-
<- 132
<-
<- *
, .
. ,
, , .
<- (=). , ,
.
7.9
,
, .
, , .
.
156
.
.
(,).
, .
.
, , : ,
.
. , ,
.
.
.
. .
, .
7.10
,
. , .
.
, .
, .
,
.
_.
(. . 10),
_.
.
,
&.
(!),
.
. ,
. 18%.
157
158
_
!
=0.18
: , _,
: _, _
!
_
!
<- * _
_ <- *
_ <- +_
!
,,. ,
, _
, _
_ _
Pascal Basic.
Pascal
PROGRAM computers;
CONST
fpa=0.18;
VAR
cost, value, quantity:INTEGER;
total,cost_fpa:REAL;
BEGIN
write( );
readln(quantity);
write( );
readln(value);
cost:=quantity*value;
cost_fpa:=cost*fpa;
total:=cost+cost_fpa;
writeln ( , quantity, :,
cost);
writeln ( : , cost_fpa:7:0);
writeln ( : , total:7:0)
END.
Basic
fpa = .18
INPUT : , Quantity
INPUT : , Value
Cost = Quantity * Value
CostFpa = Cost * fpa
Total = Cost + CostFpa
PRINT ; Quantity; :;
Cost
PRINT USING H : ######; CostFpa
PRINT USING : #######; Total
END
, , , , ,
.
:
: , ,
, .
.
.
,
( )
- .
159
160
, , , , , , -
-
.
;
;
;
;
;
;
;
1.
. , . , Pascal, ,
1984.
2.
. , Basic: , , ,
1991.
3.
. , QuickBasic , , , 1992.
4.
R. Shackelford, Introduction
Addison-Wesley, USA, 1998.
5.
6.
to
Computing
and
Algorithms,
http://www.swcp.com/~dodrill/
.
http://www.progsource.com
, ,
: Pascal, Delphi, C/C++, Java, Perl, Visual Basic.
www.cit.ac.nz/smac/pascal/default.htm
Pascal . , .
http://www.cs.vu.nl/~jprins/tp.html
, , , Turbo Pascal.
http://qbasic.com/
,
Qbasic.
www.basicguru.com
Basic. , , .
(Usenet):
comp.lang.pascal
comp.lang.pascal.misc
Pascal
alt.lang.basic
comp.lang.basic.misc
Basic
161
8.
164
,
. , ,
, , .
, , . .
.
:
, .
() .
.
.
.
.
: , .
3 ;
3
;
3 ;
3 ;
3 ;
8.1
165
,
. .
. , . , , 0.
,
0, , 0,
.
, , ,
, .
, .
.
.
<>
>
>10000
>=
+ >= (+)/
<
^2-4** < 0
<=
<= 500
=0
1 <>
166
, .
. .
,
.
,
.
,
.
(=)
(<>),
.
,
. , , .
0<<5
=1 2 3
>0
=1
<5
=2
=3
8.1.1
.
. ...,
...... ......
. _.
( ),
_.
,
>=0
< _()
_
-1
-2
-
_
> 0
_ <- _+1
_
, _, .
_
,
,
, ( ).
.......
167
168
>=0
< _()
.
_
...... :
-1
-2
-1
-2
-
_
> 0
_ <- _+1
0
__ <- __ +1
_
, ,
_.
_
.
, ,
, .
...... .
,,,,,,,
,
< 80
< 1.70
,
_
_
,,,,,
.
,
__, .
,,,,,,,
,
< 80 < 1.70
,
_
,,,,,
......_
169
170
-1
-1
-2
-
_AN -2
-1
-2
-1
-2
-
_
> 0
- <- _+1
_ <0
_ <- _ +1
0
_0 <- _0 +1
_
,
.
_
171
1
( )
. .
1-50
200,000
51-100
180,000
101-200
160,000
200
150,000
:
=<50
< *200000
=< 100
< *180000
=< 200
< *160000
< *150000
_
_
_
......_ :
=<50
< *200000
_ =<100
< *180000
_ =<200
< *160000
< *150000
_
, , ,
.
172
.
.
, :
_ >50
<=50
< *200000
_ >50 =<100
< *180000
_ >100 =<200
< *160000
< *150000
_
8.1.2
, , :
__1
_1
__2
_2
......
_
_
1,3,5,7,9
2,4,6,8
< 0 >9
_
.
, .
-.
.
8.2
, , . , .
, , _ , .
8.2.1 ...
... . , , .
173
174
... . ,
.
-1
-2
-
_
<0
<1000
< +
_
,
_ _. ,
. , _.
,
,
. .
2
, ,
.
0.
:, ,
:
<- 0
<- 0
<>0
<- +
<- +1
_
>0
<- /
: ,
: ,
_
-
, 0, .
. ,
, 0
.
.
8.2.2 _
_.
.
175
176
_
-1
-2
-
_ -
_
<- +
_ >= 1000
_ _.
( ), _ _, .
, .
_.
... _
.
_ . , _.
_
.
177
3
, . ,
( ).
2
:, ,
:
:
<- 0
<- 0
_
_
!
=<0
, ...
_
!
_ >0
<- +
<- +1
;
!
_ = =
<- /
=,
=,
_
Pascal
PROGRAM athroisma2;
VAR
x,sum,count:INTEGER;
avg:REAL;
choice:CHAR;
178
BEGIN
count:=0;sum:=0;
REPEAT
REPEAT
write( :);
readln (x);
IF x<=0 THEN
writeln ( , ..);
UNTIL x>0;
sum:=sum+x;
count:=count+1;
write( ;);
readln(choice);
UNTIL (choice=o) OR (choice=O);
avg:=sum/count;
writeln(: , sum:5);
writeln( : ,avg:6:2);
END.
8.2.3 ......
......
.
,
. , .
, . , ( _).
.
, . , ,
_.
, 1, .
179
1 2 3
-1
-2
-
_
1 100 2
<- +
_
,
. 1, .
4
100.
:,
<- 0
1 100 2
<- +
_
: ,
_
. .
....,
..
...
180
.
:
. ,
.
.
.
5
.
! 1 10
:,,
!:
!:
!:
1 10
1 10
<- *
,,,=,
_
!
_
_
Basic
DEFINT A-Z
FOR a = 1 TO 10
FOR b = 1 TO 10
c = a * b
PRINT a; x; b; =; c
NEXT b
181
PRINT
NEXT a
END
.
, , . .
:
_.
.
. , _ .
,
.
, _
.
, , ,
-
1.
2.
;
;
3.
4.
- - _;
5.
6.
182
7.
8.
_;
9.
10. ;
1.
. , Pascal, , , 1997.
2.
3.
. , QuickBasic , , , 1992.
4.
R. Shackelford, Introduction
Addison-Wesley, USA, 1998.
5.
6.
to
Computing
http://www.swcp.com/~dodrill/
http://www.progsource.com
www.cit.ac.nz/smac/pascal/default.htm
http://www.cs.vu.nl/~jprins/tp.html
http://qbasic.com/
www.basicguru.com
and
Algorithms,
9.
184
. , .
.
,
, , , .
.
.
, .
.
.
.
3 , ;
3 ;
3 ;
3 ;
9.1.
185
, .
, , .
, 30, ,
.
<- 0
1 30
<- +
_
<- /30
..
, , .
,
.
.
,
, .
30 1,
2,..., 30. .
, .
,
. -
186
, .
.
,
9.1.
. 9.1.
, .
,
[ ]. [2],
,
27.
.
i, j, k.
[i] i-
.
, , , , .
.
.
: [30]
, .
.
.
1
: [30], ,
: i,
<- 0
i 1 30
[i]
<- + [i]
_
<- /30
<- 0
i 1 30
[i] <
<- +1
_
_
:,
,
_
,
, . , ,
[i], -
187
188
,
, ,
.
,
<-+ [i].
, , . , 30 .
2
, , , 2 100.
.
N
Xi
i=1
Xi
i=1
2
N
. ,
. , , , .
, 3.
2
: i, , [100], , ,
_2,
: , _
!
( 100)
i 1
,i,-
[i]
_
!
<- 0
_2 <- 0
i 1
,i,-
[i]
<- + [i]
_2 <- _2 + [i]^2
_
!
T <- /
!
_ <- _(_2/ - ^2)
!
i 2 N
j N i -1
X[j-1] > X[j]
! j j-1
<- X[j-1]
X[j-1] <- X[j]
X[j] <-
_
_ !! j
_ !! i
!
MOD 2 =0 TOTE
<- (X[N/2]+X[N/2+1])/2
<- X[(N+1)/2]
_
!
============
=,
= ,
= , _
= ,
_
189
190
Basic
DEFINT A-Z
DIM x(100)
CLS
sum = 0: sum2 = 0
INPUT N=, n
FOR i = 1 TO n
PRINT ; i; - : ;
INPUT , x(i)
NEXT i
FOR i = 1 TO n
sum = sum + x(i)
sum2 = sum2 + x(i) ^ 2
NEXT i
mt! = sum / n
ta! = SQR(sum2 / n - mt! ^ 2) ..
FOR i = 2 TO n
FOR j = n TO i STEP -1
IF x(j - 1) > x(j) THEN SWAP x(j - 1), x(j)
NEXT j
NEXT i
IF n MOD 2 = 0 THEN
median = (x(n / 2) + x(n / 2 + 1)) / 2
ELSE
median = x((n + 1) / 2)
END IF
PRINT
PRINT =======================
PRINT
=; n
PRINT
=; mt!
PRINT =; ta!
PRINT
=; median
END
9.2.
191
, .
,
.
.
. .
. ,
100.
,
.
.
,
, .
.
.
. ,
. , , .
, .
9.3.
30 ,
-
192
30 , .
.
.
10
25
21
32
26
22
31
..
..
..
..
30
27
23
30
30 , 300 .
,
, . 27.
, (
) ( ).
[30,1] 27.
[i,j] i j , i 1 30 j 1 10.
3010.
3
( 30 10 ). , , .
_2
: [30,10], [10]
: i, j, ,
!
i 1 30
j 1 10
, i, j
[i,j]
_
_
!
j 1 10
<- 0
i 1 30
<- + [i,j]
_
[j] <- /30
_
j 1 10
<- 0
i 1 30
[i,j] < [j]
<- +1
_
_
, i, :, [j]
,
_
_
Pascal
PROGRAM poleis;
VAR
temperature: array[1..30,1..10] OF REAL;
ave:array [1..10] OF REAL;
total:REAL;
i,j,days:INTEGER;
193
,
, .
194
BEGIN
FOR i:=1 TO 30 DO
FOR j:=1 TO 10 DO
BEGIN
write ( :,i,j, );
readln (temperature[i,j])
END;
FOR j:=1 TO 10 DO
BEGIN
total:=0;
FOR i:=1 TO 30 DO
total:=total+temperature[i,j];
ave[j]:=total/30
END;
FOR j:=1 TO 10 DO
BEGIN
days:=0;
FOR i:=1 TO 30 DO
IF temperature[i,j] < ave[j] then
days:=days+1;
writeln ( ,i,
,ave[i]:4:1);
writeln ( :,
days);
END
END.
,
, . .
, . . ,
.
, 25
[1,1,1].
195
2001
10
25
21
32
2000
.
1
30
25
1
2
1999
18
31
..
23
..
10
18
32
...
22
18
31
..
...
18
30
..
25
26
22
31
...
...
...
...
30
27
23
30
21
27
22
30
26
..
26
..
2
27
21
23
10
32
30
4.
:
. .
. ,
.
. , .
. ,
.
, ,
, .
:
196
1.
, .
2.
, .
3.
,
.
.
,
.
: [10,7], i,j, , ,
: [10]
!
i 1 10
,i,
[i]
j 1 7
, j,-
[i,j]
_
_
!
!
<- 0
i 1 10
<- 0
j 1 7
<- +[i,j]
_
. ,[i], =,
<
<-
<- i
_
_
.. ,, ,[]
!
!
<- 0
j 1 7
<- 0
i 1 10
<- + [i,j]
_
. ,j,- =,
<
<-
<- j
_
_
.. ,, ,,-
_
Pascal
PROGRAM cinemas;
VAR
i,j,k,max,sum:INTEGER;
tickets:ARRAY[1..10,1..7] OF INTEGER;
name:ARRAY [1..10] OF STRING;
BEGIN
FOR i:=1 TO 10 do
BEGIN
write ( : );
readln (name[i]);
FOR j:=1 TO 7 DO
BEGIN
write ( , j, : );
readln(tickets[i,j]);
END;
END;
max:=0;
FOR i:=1 TO 10 DO
BEGIN
sum:=0;
FOR j:=1 TO 7 DO
sum:=sum+tickets[i,j];
197
198
9.4.
. :
.
.
.
.
.
.
, -
, .
:
.
.
.
.
. , , . ,
.
.
3 , 2.
.
.
, .
.
:
3
3
, .
.
.
199
200
.
.
( )
, .
.
. ( ). ,
. . .
, . .
, , , , ,
-
1.
2.
3.
4.
5.
6.
7.
8.
9.
201
10. ;
11. ;
12. ; ;
1.
2.
QuickBASIC: , , , 1991.
3.
. , QuickBasic , , , 1992.
4.
R. Shackelford, Introduction
Addison-Wesley, USA, 1998.
5.
6.
to
Computing
and
Algorithms,
http://www.swcp.com/~dodrill/
.
http://www.progsource.com
, ,
:Pascal, Delphi, C/C++, Java, Perl, Visual Basic.
www.cit.ac.nz/smac/pascal/default.htm
Pascal . , .
202
http://www.cs.vu.nl/~jprins/tp.html
, , , Turbo Pascal.
http://qbasic.com/
,
Qbasic.
www.basicguru.com
Basic. , , .
(Usenet):
comp.lang.pascal
comp.lang.pascal.misc
Pascal
alt.lang.basic
comp.lang.basic.misc
Basic
10.
204
.
. ,
.
,
,
. .
:
.
.
.
.
.
3
;
3
;
3 ;
3 ;
3 ; ;
10.1.
,
,
. 6,
, , (top-down). .
o- ,
.
.
,
.
.
1
o
,
.
.
:
. :
205
206
.
. ,
,
,
.
10.1
.
( 3)
1 2 .
, (subprogram).
. 10.1
10.2.
,
.
, .
.
207
208
, ,
.
:
.
, ,
.
.
,
.
.
.
, ,
.
. ,
.
10.3.
6.
,
:
.
.
.
.
.
.
, .
.
. , . , , .
.
. ,
,
, ( ).
,
, . , .
10.4.
.
, ,
, -
209
210
.
, .
, .
.
, .
.
,
, .
10.5.
, . .
. ,
,
. .
. , ,
.
.
.
.
, .
( ).
.
.
2
,
.
.
)
(=r2)
, ,
, .
. , . _, :
_()
_
_ >0
_
211
212
. .
, .
_(R)
.
,
.
_(R) :
=3.14
: R
_ <- *R^2
_
.
, . .
()
:,
_
:
_2
: R, E
_(R)
<- _(R)
()
_
. ,
-
. 10, :
10
: 314
, .
10.5.1
.
( ):
....
<-
...
_
. ,
.
.
, , ,
, _<-*R^2.
, .
.
<-_(R).
O , : R. R
. . , .
213
214
10.5.2
.
( )
.
, /
.
.
.
,
.
- (-)
(, , )
. .
. .
_(R)
()
. ,
_
,
. ,
_ ,
( ) R . .
. , . , .
.
.
2 Pascal Basic.
Pascal
PROGRAM example2;
VAR
r,e:REAL;
FUNCTION area(r:REAL):REAL;
BEGIN
area:=pi*sqr(r)
END;
PROCEDURE input(var x:REAL);
BEGIN
REPEAT
write ( :);
readln(x)
UNTIL x>0;
END;
215
216
PROCEDURE output(result:REAL);
BEGIN
writeln ( :,result:6:2)
END;
BEGIN
input(r);
e:=area(r);
output(e)
END.
Basic
3
DECLARE SUB Eisodos (nb!)
DECLARE SUB Ektypwsh (res!)
DECLARE FUNCTION Emvado! (r!)
CLS
CALL Eisodos(r)
e = Emvado(r)
CALL Ektypwsh(e)
END
SUB Eisodos (nb)
DO
INPUT : , nb
LOOP UNTIL nb > 0
END SUB
SUB Ektypwsh (res)
PRINT :; res
END SUB
FUNCTION Emvado (r)
pi = 3.14
Emvado = pi * r ^ 2
END FUNCTION
10.5.3
.
217
3
.
, , 1, 1, ,, 2, 2
_3 , ,, ,
, .
,, 1 _3
_3. . ,
, .
, ,
,
.
218
_3 .
,, 1
1 , ,
, .
5 7.
, 1 1 .
, _,
. (=5), (= 7),
1 (=-2) 1 (=12).
.
:
. 10.2. ()
()
()
() 1 1
.
.
, , (return address),
(execution time stack). . , . , a b,
c .
c, b, a.
,
. LIFO
.
. 10.3. .
219
220
.
. .
.
10.6. -.
.
. ( ) .
.
: A, B,
...
_
: , , ,
...
_
: , ,
...
_
221
, , , .
.
, , , ,
.
,,.
.
, .
, ,
. R
2.
.
, , .
.
, . .
, ,
.
, .
,
. .
(scope) .
222
, .
.
.
.
,
.
10.7.
.
. .
3,
,
.
,
.
,
:
:
n ( n 1) ! n > 0
n!=
n = 0
1
T ,
1 n=0.
n*(n-1)!, ,
.
.
():
!
=0
< 1
< *(-1)
_
_
():
!
: i,
Fact < 1
i 2
Fact <- Fact*i
_
_
, . , .
.
5!
().
5,
0, (4). -
223
224
, (3) (0).
(5)
<* (-1)
(4)
<* (-1)
(3)
<* (-1)
(2)
<* (-1)
(1)
<* (-1)
(0)
<1
=0 (0) 1, .
(2)=1*2, (3)=2*3, (4)=6*4 .
(5)=24*5. 120 .
225
(5)
<* (-1)
120
(4)
<* (-1)
24
(3)
<* (-1)
6
(2)
<* (-1)
2
(1)
<* (-1)
1
(0)
<1
1
. 3,
.
,
, .
.
,
( ).
( )
.
, , LIFO
,
, .
226
Pascal
FUNCTION factorial(n:INTEGER) : INTEGER;
BEGIN
IF n=0 THEN
factorial:=1
ELSE
factorial:=n*factorial(n-1);
END;
FUNCTION factorial(n:INTEGER) : INTEGER;
VAR
i,fact:integer;
BEGIN
fact:=1;
FOR i:=2 TO n DO
fact:=i*fact;
factorial:=fact
END;
asc
FUNCTION Factorial (n)
IF n = 0 THEN
Factorial = 1
ELSE
Factorial = n * Factorial(n - 1)
END IF
END FUNCTION
227
.
,
. , . ,
.
. ,
. ,
.
, .
.
, , , ,
, .
-
1.
2.
3.
4.
5.
6.
7.
228
8.
; .
9.
10. ;
11. ;
.
1.
. , . , Pascal, ,
1984.
2.
. , Basic: , , , 1991
3.
. , QuickBasic , , , 1992.
4.
R. Shackelford, Introduction
Addison-Wesley, USA, 1998.
5.
6.
to
Computing
and
Algorithms,
http://www.swcp.com/~dodrill/
http://www.progsource.com
www.cit.ac.nz/smac/pascal/default.htm
http://www.cs.vu.nl/~jprins/tp.html
http://qbasic.com/
www.basicguru.com
(Usenet):
comp.lang.pascal comp.lang.pascal.misc Pascal.
alt.lang.basic comp.lang.basic.misc Basic.
11.
230
, ,
.
,
. .
. ,
.
:
, , , ,
,
,
.
3
;
3 ;
3 ;
3
;
3 ;
3
;
11.1.
,
,
, , ,
. .
, .
. (object - oriented programming)
, .
- " ;".
, ,
()
.
, . ,
,
.
, . ,
,
-
231
232
, .
,
.
Simula
Smalltalk.
Visual C++, Java, Visual Basic, Delphi.
11.1.1.
(objects). , ,
. ,
, , (
11.1).
. 11.1.
, . , ,
.
, ,
, .. .
, ,
, .
, ,
.
, ,
( 11.2).
. 11.2 .
; .
,
,
. , (data)
(operations) . (methods).
,
.
, , . , . , , , , , ,
11.3.
233
234
. 11.3 .
, , . , , , .
. ,
. , , .
11.1.2.
,
. ,
. , . -
. , (instance)
.
(class) .
. . . , , .
11.1.3.
.
. ,
(attributes properties),
.
.
, , ,
, .
,
,
.
,
(properties window), .
,
235
Smalltalk, , , ,
.
(metaclass).
236
, , . :
(Data abstraction). .
.
. .
(Encapsulation). , ()
(). .
.
,
.
(Inheritance). .
(subclasses) .
()
.
, , , ..
.
(Polymorphism). , , ,
.
. . , . ,
, . .
.
,
. , Visual C++ Visual Basic, :
. =
. .
11.1.4.
,
Smalltalk Visual Basic, (methods).
. .
. .
,
. :
.
237
238
11.2.
(event-driven programming) ,
, .
, , .
.
,
.
. ,
, , .
,
, ,
.
, .
(event) , , .
, .
, ,
,
..
.
239
11.2.1.
, ,
.
, ,
(event procedures),
.
. , , .
:
_
...
...
To ,
.
,
, .
,
.
, ,
:
.
, Visual
C++
(functions).
240
...
...
:
_
...
...
.
(modular) , , (structural) , .
,
, ..
.
11.2.2.
, :
1.
2.
3.
, .
4.
, .
5.
( 2).
. . , , .
11.3.
,
.
.
,
(user interface). , . ,
. .
.
,
. .
241
.
. .
242
, . . , .
:
1.
-, .
2.
3.
, , ,
.
,
.
,
.
. :
,
,
243
.
.
(toolbox)
.
, .
. , .
.
, :
( ) ,
,
,
,
:
1
2
3
244
,
. 1,
,
.
,
.
. , .
, :
, ,
,
,
.
:
0
245
( )
,
.
.
. 11.4.
, 11.4.
,
. .
.
246
, .
.
, , .
:
,
, .
.
,
.
:
1_()
1. =
2. =
3. =
2_()
1. =
2. =
3. =
3_()
1. =
2. =
3. =
_()
, , . . ,
, , .
, .
(
11.5).
. 11.5.
( 11.6).
247
248
. 11.6.
,
.
11.4.
. . ,
.
, Visual C++,
Delphi Visual Basic,
. , ,
. , .
, , , ,
, , ,
. ,
, ,
,
.
,
. , (toolboxes),
(debugging tools), (code windows),
(report generators) . (wizards) , .
,
,
.
,
.
.
11.4.1
(menus) , , .
.
(menu bar)
( 11.7).
249
250
. 11.7.
, (Menu
Editor).
. 11.8.
251
. 11.9.
, (toolbars) ( 11.9).
.
11.4.2
(dialog boxes) ( 11.10) . . , .
. 11.10.
. , ,
,
.
, -
.
.
252
11.5.
, .
, .
, , .
,
.
, .
(document-centered
view)
(multitasking).
. ,
, ,
, , ,
( 11.11).
,
. ,
.
. 11.11.
, (linking)
.
, . ,
, ,
.
.
, ,
. .
,
(real-time)
. , , ,
:
253
254
,
(embedding)
. .
.
, , .
. .
. ,
,
. .
, ,
. .
. , .
, .
,
,
,
.
, , , , .
, . ,
,
. ,
, .
,
, .
.
,
.
. , .
,
, , , , , -, , , , , , .
255
256
-
1.
2.
3.
4.
5.
6.
7.
8.
9.
10. ;
11. ;
12. ;
13. .
1.
2.
3.
4.
5.
. -. : Visual Basic
4.0, , , 1997.
http://iamwww.unibe.ch/~scg/Ooinfo/
Internet, .
http://whatis.com/oop.htm
.
http://oop.cs.technion.ac.il
.
www.oop.com/frameworks/delphi/
Delphi.
http://www.humboldt.edu/~jsb7/C/WIN95/events.shtml
.
http://midrangecomputing.com/mc/97/05/
.
http://service.shu.ac.uk/schools/sci/maths/jw/jw/vbintro/
Visual Basic Delphi.
http://www.cnet.com/Resources/Info/Glossary/Terms/ole.html
OLE (Object Linking and
Embedding).
257
12.
260
. , , (user
interface) . , ,
.
.
:
,
3
;
3 ,
;
3 ;
3 ;
3 ,
;
12.1.
(user interface)
.
, ( 12.1).
, .
, .
. 12.1 :
, (lightpen) . , , , , , ,
. , , ,
, ,
.
.
.
, .
261
262
, Standard Directory of
Electrical and Electronics Terms, interface
shared boundary, .
( ) interface
. interface , , .
, .
, ,
.
.
, , .
. ,
.
12.2.
,
, ,
. , (,
) ,
, .
(command-based). -
, , . DOS. , .
, .
.
DOS, DOS (dosshell), DOS (Norton
Utilities, ). , , ,
.
Apple.
Apple
,
GUI (Graphical User Interface).
,
,
.
,
PCs,
.
, Windows S/2. Apple.
Macintosh Apple
.
GUIs . , , clicks .
GUI
. , , -
263
264
:
: , .
:
. . ( 12.2):
3 ,
,
3 (title bar),
,
. 12.2: .
3 (menu bar),
,
3 (toolbar), ,
3 (status bar), ,
3 (scroll bars), ,
, ,
3 (control menu),
,
3 (maximize button),
,
3 (minimize button), ,
3 (restore button), ,
3 (close button), .
:
. . , (, , ).
:
.
.
265
266
12.3.
,
,
.
.
;, . ,
,
, ,
(user task analysis).
,
. ,
.
:
: , , , .
, ,
.
,
,
.
: , . , ,
.
:
. ,
video
,
video,
.
: .
.
. , ,
, .
,
, . , ,
.
: , .
.
.
, ,
.
:
.
:
267
268
3 on line , .
, , ,
.
3 , (assistants)
.
.
3 ,
.
: , . , .
:
. ,
. ,
, ,
,
.
.
: . ,
; (/), ;
(/), ( , ).
.
269
................
!
, , ,
()
................
()
<- 0
_
(/);
, , , n
<- 1
, , ,
<- 2
_ =1 =2
, , .
. ,
, .
.
. .
( 12.3) :
,
.
270
. 12.3.
, ,
, .
,
.
, , . , .
,
.
, , .
,
,
.
12.4.
,
.
12.4.1.
. , .
,
. ,
.
: , , . ,
. , ,
, . :
,
,
,
,
,
.
. .
.
12.1.
271
272
12.1 :
.
.
:
. . , , , .
.
,
. .
. .
, .
273
. , , , .
. , .
.
.
.
12.2 .
12.2 :
12.4.2.
. , ,
. , -
274
.
.
,
,
, :
. .
, .
,
.
. ,
.
.
. . ,
.
.
. .
12.5.
.
, .
, , .
. , :
:
. . .
.
.
,
.
.
, .
. . ,
.
:
, .
. , , .
, .
, .
:
. .
, , -
275
276
. , . ( )
.
(user
interface) . ,
(GUI). , . .
.
(user interface), , , ,
-
1.
user interface
.
2.
3.
GUI.
4.
5.
6.
7.
277
;.
1.
2.
3.
4.
5.
6.
: , , , , 1994.
7.
http://cfg.cit.cornell.edu/cfg/design/contents.html
, ,
, , ..
.
http://www.depauw.edu/~dberque/hci/bell/index.html
Ben
Shneiderman Designing the User Interface , .
278
http://www.depauw.edu/~dberque/hci/chauner/main.htm
, , ,
, ,
.
http://www.sju.edu/~jhodgson/gui/guihome.html
. ,
.
13.
280
, , , . , , .
, .
, .
,
,
, ,
.
:
.
.
.
.
3 ;
3 ;
3 ;
3
,
;
3
;
281
13.1
, , , .
,
.
, :
, . .
, , .
, , .
, . , . ,
.
,
(crash) .
,
.
(bug)
. ,
bugs, .
282
, ,
.
,
, ,
,
,
.
.
, .
(testing) .
2000 (millennium bug). ,
.
:
1962 Mariner 1 Canaveral
. ... (NASA) , -
.
. NASA
FORTRAN . 80 .
1990 AT&T, . 5
.
Pentium 1994 ,
.
Thomas Nicely Lynchburg
Virginia . ,
450
1995 Denver .
. , .
,
3,2 .
283
284
13.2
,
(debugging).
.
,
. .
, .
, , ,
. , .
.
.
13.3.
. .
. ,
.
,
.
(debuggers).
,
.
:
(watch expressions)
. ,
,
.
.
. 13.1.
(breakpoint) .
.
, .
, .
.
285
286
. 13.2.
(history)
.
.
, . (tracing) ,
.
.
. 13.3.
(.. , ), .
,
,
, .
13.4
.
, .
287
288
.
, .
. , .
, .
:
,
.
,
(exception error handler), . .
,
.
Java, ADA C++ (exceptions),
Visual Basic (On Error GoTo).
:
.
.
, .
, , , .
, . (..
) , .
, .
,
.
. ,
( ) .
.
.
.
.
.
,
.
, , , ,
.
-
1.
289
290
2.
3.
4.
5.
1.
, , 2, , 1986.
2.
. -. : Visual Basic
4.0, , , 1997.
3.
http://www.alsplace.com/home/pages/famous_bugs.htm
.
http://www.bugnet.com
.
http://www.guide-p.infoseek.com
.
http://www.netstuff.com/computerbug
.
http://www.techweb.com
, ,
2000.
http://www.year2000.co.nz
2000.
14.
-
292
.
,
, . , ,
, . VTOC (Visual Table
Of Contains), .
.
:
, .
.
( , ..).
.
.
.
3 ,
;
3 ;
3 ;
3 ;
293
14.1
, , .
. . :
3 ( , )
3 ( , )
3 ( )
3 ( )
3
, , ,
, , .
. . .
,
. ,
. ,
, .
14.1.1 -
, . ( ), ,
. , -
,
, .
294
. , , .
. :
3 .
3 .
!!
,
, .
.
1
1000 . ,
. .
:
, , .
(<>), , , (=) .
.
2, 2, 3, 3, 3, 3, 5, 6, 6, 6, 6, 6,
7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9.
:
295
.
1
: i, S, _, A[1000]
i <- 1
S <- 0
_ <- [i]
i < 1001
_ <> [i]
_, S
_ <- A[i]
S <- 0
_
S <- S+1
i <- i+1
_
_, S
_ 1
2
: i, S, _, A[1000]
i <- 1
S <- 0
_ <- [i]
i < 1001
_ = [i] i < 1001
S <- S+1
296
i <- i+1
_
_, S
. <- (i)
S <- 0
_
_ 2
3
: i, S, _, A[1000]
i <- 1
S <- 0
_ <- [i]
i < 1001
_= [i]
S <- S+1
i <- i+1
_ , S
_ <- [i]
S <- 0
_A
_
_, S
_ 3
.
. (i).
(i),
, (i).
(i).
i
i<1001. _(i). , .. i<1001, i .
, ... .
, (=) (<>),
...TOTE....
:
3 .
3 , .
3 , .
,
(i) .
., S , .<-(i), s<-0" . , . .A, S ,
, ,
. , s<-0, .A<-A(i)" . ,
.
s<-s+1.
14.1.2
. ,
, , ,
.
. ,
.
,
, 3
.
297
298
4 .
,
.
, .
2
.
_2
,
,
<
,
,
_
_ _2
, ,
.
;
.
3
.
3 6 (3!=1*2*3=6). , .
_3
, ,
, ,
<
<
, ,
<
,
,
_
_
<
, ,
<
,
,
_
_
_
_
,
,
,
,
_3
, 24 (4!=1*2*3*4=24) , , .
, ,
, .
,
, .
,
, . ,
, 16%,
, , 50%.
.
.
299
300
.
.
_2
,
,
>
temp <-
<-
<-temp
_
,
_ _2
,
.
, , .
.
_3
:
, ,
<- 0
, ,
=0
<- 1
>
temp <-
<-
<- temp
<- 0
_
>
temp <-
<-
<- temp
<- 0
_
_
, ,
_ _3
301
, . =1 . , ( ),
. > > , .
(>) (>, >).
.
.
14.1.3
.
, ,
.
,
, .
.
, .
.
,
, .
, .
. .
, ,
. ,
; .
,
. .
.
302
. ; ,
.
(,
, ), . : , ;
12; 32;
, .
:
3 ;
3
;
3 ;
:
.
.
0 1.
.
.
I, V, X, L, C, D, M, .
,
.
. ,
.
, . ,
. .
, , , .
,
.
.
4
.
,
.
365 , , 366.
, , , , ,
31 .
, , , 30 .
28 , ,
29.
4,
100, 400. : 1984 ( 4), 1900 ( 4 100), 2000 (
4, 100, 400), 1993 .
.
4 1582
. 4 15 .
10 1923. 10
23 1923.
303
, .
304
_1(, , , c)
!
c <- 0
>0 >0 >0 c <- 1
_ _1
_2(, , , c)
!
c <- 1
(10< <23) =3 =1923 c <- 0
_ _2
_3(, , , c)
! ( =1 )
4 <- mod 4
100 <- mod 100
<- 1
_
_
! (c=1 )
c <- 0
1, 3, 5, 7, 8, 10, 12
<=31 c <- 1
4, 6, 9, 11
<=30 TOTE c <- 1
2
=0 <=28 c <- 1
=1 <=29 c <- 1
_
_ _3
_2. ,
.
.
, .
. .
.
14.1.4
, . :
. , (quick
305
306
sort), ( ) ,
,
,
, ,
,
, .
,
, .
5
, .
( ).
.
number>0
<- +1
_ number<0
<- +1
<- +1
_
number<0
<- +1
_ number>0
<- +1
<- +1
_
number=0
<- +1
_ number<0
<- +1
<- +1
_
;
,
, ,
.
2 .
6
1000 . ,
.
3. , ,
. ,
.
:
.
,
.
,
.
, , .
307
308
. ;
12345. 6 :
6 =(1*1+2*3+3*5+4*7+5*13) mod 11
=(1*1+2*3+3*5+4*7+5*13) mod 11 =(1+6+15+28+65) mod 11 = 5.
123455.
, , 6, ,
1000 .
6 : ,
. 11.
. 11 0
10. 10, 6 0.
.
,
.
, ,
1000 ,
, .
,
, ISBN .
14.2
.
14.1 .
309
,
.
. 14.1.
: .
.
,
, .
310
14.2.1
. , , , .
. .
. . (test file), , .
14.2.2
. ,
, . .
. (test file)
,
. , .
.
. (users manual).
. ,
. . , , , .
-
.
.
:
- - .
, .
, , .
. ,
.
.
.
.
. , ,
.
.
,
, . . .
7
.
.
. , , .
. . -
311
312
2000
,
, ,
,
. , , ,
. ,
,
, .
, , ,
.
.
HIPO (Hierarchy plus Input Process Output). ,
. .
(Visual Table Of Contains, VTOC).
.
- (Overview Hierarchy plus Input Process Output, Overview
HIPO). , ,
.
, ,
(Detail HIPO). ,
.
, VTOC,
. ,
, ,
. ,
. , .
VTOC
.
. 14.2. VTOC
14.2 , . , . , . ,
.
313
314
, ,
. (
), 0000.
1000, 3000 ...
9000 ( 1000, 3000 .). , .
,
. 1100
1300 1000 ..
.
, , , ,
, . , , .
,
. , , , .
, .
3
l
, ( 3 , , , ).
.
, ,
.
, .
.
14.2.3
. , , , ,
, ,
, . , .
.
, .
14.3
, (, , ).
,
, , , , o
(version).
, . , ,
, , , (DOS ver.5 DOS ver.6),
, (Windows v.3.1, Windows
v.3.11). . ,
(Windows 95, Windows98, Office 97 .).
,
, MS-DOS Windows.
315
316
, ,
.
; ;
. .
, , ,
, . ,
, , .,
, , , , ,
, .. ( ).
,
, , , .. ( ).
, ( ).
. ,
( ).
. ,
(
).
, ,
14.3.
.
, .
, , .
. 14.3.
, :
3 .
3 , .
3 .
3 (, )
.
3 (modules) .
3 .
, :
3 . .
3 . (source program).
3 , .
(object program).
317
318
3 "
.
3 , .
:
,
,
.
. .
3 ,
, .
3 .
3 .
3 .
3 , .
. ,
, . .
.
. :
3 .
3
.
3
.
3
.
3
. ...
.
14.4
.
. 14.4.
.
.
,
.
.
.
319
320
, .
.
VTOC
.
, , HIPO, VTOC,
, .
1.
2.
3.
3 ;
4.
5.
(VTOC).
6.
7.
8.
9.
10. ;
11. ;
1.
2.
, , 1986.
. , , , 1992.
http://diamond.idbsu.edu/~philmac/cs125/980331.htm
.
http://129.219.88.111/softeval.html
.
http://www.acm.org/pubs/toc/Abstracts/cacm/62963.html
, , , ACM (Association of Computing Machinery).
321
................................48
Fibonacci ......................................................72
......................................57
..................................................86
...............................................58
..................................................89, 90
.................................................54
...........................................58
() ........................69, 223
() .............................70, 223
.......................................70
() ....................71
() .........................71
.........................................91
......................................175, 177
.............................................................180
, .............188
............................................295
....................................298
..............................................303
algorithmic languages
.
algorithm
.
alphanumeric ,
.. .
recursion .
recursive function
, .
analysis
.
object .
.
object program .
328
data ,
, .
index ,
.
pointer .
tree .
,
, .
,
.
read , .
procedural language
.
interactive
() .
interface
, , , .
interpreter
.
program testing and debugging .
program testing
.
.
structure
programming ,
.
: ,
.
debugging .
debugger , ,
.
assignement .
software testing
.
instruction
, .
program
verification
.
iteration
.
data processing
.
: , , , ..
software tools
.
application
.
software life cycle
, ,
.
code
() linked list
(pointer)
.
software
, ,
.
variable ,
.
329
control variable .
compiler
.
event driven
.
accuracy 1)
. 2) .
.
queue
.
error trapping
, . , .
software package
.
software piracy .
software
development environment -
330
access
.
table
.
breakpoint
.
() information , , , ,
.
constant
.
() program .
,
.
programming .
programmer , , ,
, .
program
specification
, .
append
.
bottom-up approach
.
stack
.
string
,
.
merging
.
.
assembly language
.
.
assembler .
condition ,
.
bug .
program design
. .
sorting .
program
documentation .
operand
.
operator
.
artificial intelligence -
331
.
subprogram
,
.
natural language
, .
nesting H .
pseudocode
.
a posteriori=
background=,
chart=
a priori=
backslash= \
check digit=
abstraction= ()
backtracking=
check sum=
access=
backup=
checking=
accessing=
bar chart=
choice=
accidence=,
bell= ,
class=,
accuracy=
benchmark=
clear=
activation=
beta test=
client=
actual=
blank (character)=
clipping=
aid=
blinking=
code=
algorithm=
block=
coding=
alignment=,
bookmark=
collate=
alphanumeric=
colon= :
box=
combination=
alteration=, ,
column=
ambersand= &
braces= {}
ambiguious=,
brackets= []
ambiguity=
break key=
analysis=
break=
analyst=
breakpoint=
command driven=
analytic=
browse=,
command language=
animation=
bubblesort=
command line=
annotation=
bug=
comment=
append=
build-in functions=
compact=
business applications=
compatibility=
application=
approximate=
argument=
array=
artificial intelligence=
assembler=
assembly language=
assignement=
at sign= @
attribute=
authentication= ()
authoring languages=
button=
call=
call-by-reference=
call-by-value=
cancel=
caret= ^
carriage return character=
catalog=
cell=,
certification=
character code=
automation=
character set=
auxiliary=
character=
combining=,
comma=
command=,
compare=
compatible=
compilation=
compiler=
computability=
computational complexity=
computational=
computer instruction set=
computer science=
concatenation=
concept=
conception=,
334
conceptual=
decrement=
condition=
default value=
conditional branch=
default=
conjuction=, , ,
/
definition=
constant=
definiteness=
delete=,
deletion=
constraint=
delimiter=
consultant=
demo(stration)=
context=
design=
continue=
control character=
development=
diagnostics= ()
control point=
diagram=
control variable=
diagramming technique=
convention=
conversational=
conversion=
copying=
correction=
counter=,
create=
cursor=
customer=
cut=,
cut-and-paste=
data=
data capture=
data compression=
data definition=
data entry=
data flow=
data processing=
data structure=
data type=
date=
debugger=,
debugging=
decision=
declaration=
entity=
entry=,
enviroment=
equal=
equation=
equivelence=
erase=
error=
error trapping=
escape=
evaluation=,
even=,
event=,
digit=
exclusion=
digital=
executable=
dimension=
execution=
directive=
exit=
directory=
expandability=
discrete=
exponent=
disjunction=, ,
expression=
display=
failure=,
data base=
enhancements=,
download=
dummy instruction=
dump=
duplicate=
dyadic operation=
dynamic=
editing= (, )
factorial=
false=
fault=,
feature=
feed=
feedback=,
field=
file=
finiteness=
flag=,
flow chart=
font=
editor=
foreground=
effectiveness=
form=, , ,
efficiency=,
formal=
element=, ()
format=
embedding=
formatting=
empirical=
free text=
emulation=
function=
encapsulation=
global=
335
graph=
job=
monitor=,
greedy method=
join=, ,
move=
hardware=
jump=
multimedia=
heap=
justification=
natural language=
help=
key=
heuristic=
keyword=
negation=, ,
hyphen=
label=
hyphenation=,
landscape=
icon=
library=
identifier=
)
(-
ignore=
image=,
immediate=
implication=
implicit=,
implied=
improvement=
incompatibility=
indent=
index=
infinite loop=
information=
information processing=
inheritance=
input=
insertion=,
installation=
instance=
instruction=
integer=
interaction=
interactive=
interface=
interpreter=
interrupt=
intractable=
intricic=, ,
inverse=
italics=
item=
iteration=
nested=
nesting=
nomenclature=
numeric=
licence=
object=
life cycle=
link=, ,
linked list=
linker=
object driven=
object oriented=
odd=,
linking=
list=
office automation=
listing=,
office=
literal=
O-notation=
loader=
operand=
local=
operation=
logic=
operator=,
logical=
optimal=
loop=
option=
machine language=
optional=
macro (instruction)=
order=
main program=
ordering=
maintenance=
output=,
manipulation=
overflow=
manual=,
overlay=
map=
package=
mark=
parameter=
mask=
parity=
matching=,
parsing=
matrix=
password=
menu= ,
paste=,
merging=
patch=
mirroring=
pattern=
mode=,
performance=
modify=,
permission=
modular=,
permutation=
module=,
planning=,
()
monadic operation=
platform=,
336
structure programming=
pointer=
reserved word=
polymorphism=
restart=
polynomial=
retrieval=
pop=
return=
portability=
row=,
portrait=
rule=
precision=
run=
primary key=
save=
print=,
scalar=,
procedure=
scope=
processing=
scroll bar=
program=
scrolling=
prompt=
searching=
property=
secondary key=
pseudocode=
semantics=
separation=
push=
sequential=
quantity=
queue=
quit=,
quotation mark=
subprogram=
subroutine=
sum=
syntax=
table=
testing=
text=
time complexity=
tool=
toolbar=
toolbox=
tracing=
transform=
sequence=, ,
translate=,
translator=
trapping=
serial=
tree=
set=
trial=
shift=,
unary=,
simulation=
software=
unconditional jump=
sorting=
underflow=
source=
underscore= _
real=
space
undo=
record=
specification=
recursion=
radian=
rank=
read=
ready=
reference=,
relation=
relative=
release= ()
reliability=
replica=
reply=
report=, ,
()
requirement=
rerun=
reserved=
complexity=
update=
stack=
user=
utility program=
validation=
standardization=
statement=,
)
upgrade=
(-
variable=
verification=
static=
verify=
status=
version=, ,
step=
virus=
visual=
string=
window=
structural=
watchpoint=
write=
.-., , , , 1994
al Khowarizmi 25
64
29
ALGOL 120
16, 81
10
Allen P. 122
- 317
28
232
128
Bolzano 87
138
210
Clipper 126
85
293
241, 261
301
90
293
85
88
100
26
60
152
Fibonacci 72
253
138
219
53
8
157
123, 132
85
74
87
67
LIFO 59, 62
236
67
25, 155
285
284
Kurtz T. 122
LOGO 123
NP- 111
OCCAM 137
Papert S. 123
138
40
PASCAL 123
PROLOG 122
238
Ritchie D. 125
4 127
SMALTALK 235
- 128
SQL 129
- 118
VTOC 312
- 119
- 118
130
248
315
138
31, 153
285
154
282, 318
28
220
37
236
254
26, 155
75
39, 173
25
97
130, 148
8,
32, 165
286
25
69, 222
75
297
30
128
338
25, 71
101
111
60
118
105
235
69, 222
154
109
132
137
286
209
286
67
26
11
26
138
56, 185
118
153, 210
128
138
156
140
131
318
ASCII 326
8, 53
66
236
67
104
305
110
308
28
216
31
31
130
17
132, 205
5
234
67
236
315
281
130
73
282
165
70
233
87
249
31, 151
138
127
- 16
- 16
- 17
- 17
216
293
148
- 17
130
- 111
- 16
- 17
- 17
117
317
110
207
137
111
138
28, 130
110
64
125, 238
131
46
285
308
45
31, 149
150
63
125
56
60