You are on page 1of 270

i

1.1 .:
- : . ,
,

No 15:
/

- : ,

- : I. ,


,
.


,
,
,
,
/ , .Sc. , ,
,
, . , 19


( )


/ , 19
, 19
,
/ ,
,

:
-

:
, 49, 106 82, , . 38.45.594

:
/ (), 16, ,
.: 3645274, e.mail:epy@epy.gr
: . , ... , ..

. , . , . , . ,
. , I. , .



( )

13

1.

25

2.

39

3.

75

4.

109

5.

129

6.

145

7.

155

8.

165

9.

181

10.

193

11.

207

12.

223

13.

233

14. -

241

255


,
, ,

. , ,
.
,
,
, ,
, .
. , ,
. ,
. . , , , ,
.
' , , , , .
14 ,
.
:

10

' , '
: , , ,

^

& , ,
, .
,
,
,
, .
, .
.
, , ,
/ , .
, , , -

11

'.
, '
, 50 ,
.
,
, , .

, . ( , ).
,
,

.
0 - -
,

.
, .
, ,
.

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

14

'
,
. ,
. . ,
.

:

, ,



. . :
:

15

/
,

,
,


. .
:

16


,
, ,
,

,

, ,
,
.


,
:

, , :

77

,
,
.

.
, ,
.

.
, .
.

,
. ,
.
:


,
,

,

.

18

, ,
.
:
,
,
,
.
, , . '
( ).

. .

.



.
/ . , . ,
.

19

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

( ) .




( )


( , )


( )


( )


( )

. .

20

, 58
(29 ). , ,
.

,
,
.
, , ,
.
, .
. , , , ,
.
:

, ,

,
,

21


.

' .
,
:
: , .
: , ,
.
:
.
: , .

.
.
. ,
, . , ,

,
, , . ,

,

22

, .

. ,
. , ,
. . , .

, , :

. ,
.

-. ,
. ,
, .

'

. ,
. . ,
.

.
. :
, ,
,
.

23

. ,
, . ,
. '
, .

. , . .
.

,
, , .


.

1.1.
.

26

1.2.
, :

,
,

1.3. -

:

1.


.
.
.

2.

,
. , , , , .
, .

3.

" "
. -

27

" "
. " " .
)
1.

1.4.

(2)

1

1 :

28

(
)

( , , , )


,
, ,
( 1.2.1).

, :
5
1 2.
:
1 2.
1 . (
).
.

.

29

1.

2.

3.

4.

,
, .

5.

1.

2.

3.

4.


1 :

2 :

A3 :

4 :

1:

2:

3:

4:

5 :

2

2 :

30

(
)


,
, ,
( 1.4.).

, 1, ( 1.4.).
.

, :

4 5 ( ).

57

5
-*3 .
:

3 4.

1.

2.

3.

1.

:
)
)
)
)

2.


)
)
)
)

32

1.

2.


A1 :

2 : A3 :

B1 : , y,

2 : , ,

1: 2:

1.5.

.
:

1.6.

([> ,
.

http://members.tripod.com/~ideas/workshop.html

http ://www.wcape.school .za/malati/Probsolve. htm

http://www.viabilitygroup.com/Pages/ProbSolvOTL.htm

http://www.stemnet.nf.ca/Curriculum/Math/lntermediate/problems.htm

http://www.roma.unisa.edu.au/11571/module3_11571/index.htm

http://www.hsdg.com/ps.htm

35

1.7.

1.

- ' - :
( ), (' ), '
(' ' ), ( ),

2.


(
;), , .

3.

4.

1.2.

5.

6.

1.5.

7.

1.6.

8.

, .

9.

:
. , -

34

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

1.8.
>

.
,
,
.
)

,
( ).
15 ,

15 . ,
.

.
, , .

2.
. . : , .
, .

3.


: ) , , , , , ) , , , , .
4.
, ,
.
5.

.
( ) .
. .
.
. "
" "
". (query)
, .
6.
.
. .
. , , "" "" . : ( - ),
( - ), (
- ), ( - hackers).

36

>

.
.
, , .
: , .
, .
( ) ( ). .
.
.
2.
.
.
,
. ,
. ,
, . , , .
3.

.
: ) : server, , , ) :
, scanner, videocamera, , , ) -

37

: , fax/modem, ) /: , barco overview display.


4.

.
, ,
.
5.

.

,
. ,
, 20.
,
,
.

2.1

,
.

40

2.2
, :

2.3 -
:

, .
. 0 .

41

.
.

.
. 2.9.

2.4

(3)


, .

42

: ' , .

: .

: .

: .

:
.

2.1 2.4.2 . 5 1-8 .

1 2
.
'
1 2 , 1 2
.

10 15

43


1.

2.

' .

3.

4.

5.

6.

, ,
.

7.

8.

9.


10. :
)

11. :
)

) /

12. :
)

44

13.
138
) = 1 3 8

) = :138

) : =138

) < - 1 3 8

14. :
)

15. :
) + = 10

) < - * 3

) + < - 1 2

) < - 2 * < - 2 2


1:

6:

11:

2:

7:

3:

8:

12:
13:

4:

9:

14:

5:

10:

15:

2

:

45


, .

.
. .

.
.

.
.

. ... .

2.4.3 2.4.5 . 10,11 .

3 5
.

46

'
4, 6 8 ,
5, 7 9 .


8 12 .

1.

2.

, .

3.


( ).

4.

5.

6.

... ....


7.

... :
) )
) )

8.

:
) )
)

9.

47

10. 2 :
)

11. 2 :
)

12. :
)

48


1:

7:

2:

8:

3:

9:

4:

10:

5:

11:

6:

12:

3

' :

' .


, .

:
.

49

: :
)

<>

_ < >

1 2

. , .

2.4.5 2.5 . 2.4.5


.
9 , 1 2 , 1 3
.

5 6
.
'
3, 5 7 ,
3, 7 8 .

50


8 12 .

1.

,
, .

2.

3.

4.

"..."
.

5.

_..._...
.

6.

" i .. ..
.


7.


, .

8.

... ()

9.

10.
1 2 .
11.
.

, -

51

12. '
..


1:

7:

2:

8:

3:

9:

4:

10:

5:

11:

6:

12:

2.5

' .

2.6
,
.

2.7
1.

"". 2.1 .

2.

. 2.1 .

52

3.

.
2.2 .

4.

; '
, .

5.

. 2.3 .

6.

/ ; ( , ),
, , .

7.


. 2.4.1
.

8.


. 2.4.2

9.

. 2.4.5 .

10.
. 2.4.3 .
11. . 2.4.4 .
12. "
". 12

55

13. " ". ; 12 .

2.8
>-
1.

L, g

2 * 3.14 * (/9)

2.

12 3J0
lira < 550
dollar
marko < 100
synolo < 1025*lira+2234*dollar+3459*marko
synolo

: , .

3.
1.
_0
ATHR <- 0
i 1 100

54

HLIKIA
ATHR <- ATHR+ HLIKIA
_
MO <- ATHR/100
// //
_
2.

5 .


ATHR <- 0
1 5
VATHMOS
VATHM0S>100 ATHR <- ATHR+VATHMOS
_
// ATHR //

4.
1.

2.

3.

4.

5.

6.

5.

// , //
<0.35
""

""
_

55

<0.17
""

""
_

6.
3 ( 1) . :
0>18
""

"-"
_

7.

// MISTHOS//
MISTH0S<150000
EISF1 <- 0.05*MISTHOS
EISF2 <- 0.04*MISTHOS
_ MISTHOS<250000
EISF1 <- 0. 075*MISTHOS
EISF2 <- 0. 06*MISTHOS
_ MISTHOS<400000
EISF1 <- 0. 095*MISTHOS
EISF2 <- 0. 08*MISTHOS

EISF1 <- 0. 12*MISTHOS


EISF2 <- 0. ll*MISTH n S
_
ESIF1, EISF2, MISTHOS-(EISF1+EISHF2)

56

8.

3 ( ') . '
MAX .

< - 1000000
MAX < 0
.

9.

"'

""

57


// //
=1
" "
_ =2
""
<_ =3
""
_

10.

// 1,2,3,4,5,6,7,8,9,10 //
ATHR <- 1+2+3+4+5+6+7+8+9+10
MO <- ATHR/10
1>0 101
2> 102
3> 103
10> 110

10

.

(.. ) .

58


1.
200 , ( )
10.

2.

xronos < 0 . 5
arhiki < 295600
prosfora < 256000
deval < l-(prosfora/arhiki,1/xronos)
deval

'
arhiki, prosfora, xronos.
: .
. .
deval < - 1-(prosfora/arhiki)

3.

poso < 5000
agores < 0
e u r o < 34 , 7 5
flag <r~
_
eidos
timi < eidos/euro

(1/xronos)

59

agores+timi<=poso*euro
agores
agores+timi

flag <
_
flag=A

4.
x=13 ' 40, 20, 10, 5, 16, 8, 4, 2, 1
= 9 28,14, 7, 22,11, 34,17, 5 2 , 2 6 , 1 3 , 40, 20,
10, 5, 16, 8, 4, 2, 1
= 2 2 11, 34,17, 52, 26,13, 40, 20,10, 5,16, 8,
4, 2 , 1

= 1 .

5.

3 ( 1).

6.
. 100ml
.

// _, _, _, _ //
_ <- 195/3
_ <- 205/4
_ <- 400/5
_ <- 450/5.5
<-

60

i <r- 1
_<
<- _
i < 2
_
_<
<- _
< 3
_
_<
<- _
i <- 4
_
// i, //
_

7.

2 .
.

8.

// si, s2, s3 //
si <- 0
s2 < 0
s3 < 0
i 1 100
El
1 = 1
si < sl+1
_ 1^2
s2 t s2+l
_ 1=3
s3 < s3+l

61

_
_
// si, s2, s3 //

9.
_
! price capacity
, donation
pricel,capacityl
MAX < capacity
cost < pricel
price2,capacity2
capacity2>MAX
MAX < capacity2
cost
price2
_
price3,capacity3
Av capacity3>MAX
MAX < capacity3
cost <- price3
_
donatel, donate2, donate3, donate4, donate5
count < 0
Av donatel>=cost count < count+1
Av donate2>=cost count < count+1
Av donate3>=cost count < count+1
Av donate4>=cost count < count+1
Av donate5>=cost count < count+1
// count //

2.9
, . -

62

)
1. , . (+).
. ,
.
(infix) ,
. , :
<- +
, .
, . , " = " ""
. . :

BASIC,
- LET, .. [LET] x = a + b .

C .

Pascal ": = "... x : = a + b .

COBOL ..
ADD GIVING
- COMPUTE, ..
COMPUTE = +

y < *

63

y .
,
y <- *(+)
,
.
:
_1
//, , //
y < *(+)
// y //
_1

, , ,
. , .
. - (bold) . .

) -
.
2. , , . (+)/.
2, . "
2 " .
= 0 .
- "...".

64

.
2.
// , , , //
<- *(+)
^ y < /
// y //
_2
' ' ,
....
(sequence). ....
... , . . , . ..
<>
<_1>
<_2>
<_>
_

, .
<>
<>
_

_2 . = 0 ;
.
)

...... . ..

65

_2.
/ / , , , //
<- *(+)
*0
y <- /

" "
_
// / /
_2
)

, . ..

_2.
// , , , //
flag

4- * (+)
^

flag <
_
// y, flag=, //
_2
)

(), , y flag. ..

_2.
// , , , //
flag <
<- *(+)
*0
y <- /

flag <
_
// , flag //
_2

66

' ,
. y, " ". ,
" , , , ".
, :
I)

II)

, -. .
3. 3 , y, . .

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

Max
// , , //
<-

Max
//, , //

> <-
> <
// //
Max

y >
>
*-

- y

>

*-

Max

////

67

)
Max
//, , //
>=
-

>=
y >=

y >=

- y

*-

Max

////

() < > ......


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

)
, .
, .
4. 1
100.

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

68

100 "1", "2", .. .


1 . ...

. 1.
, i, 1 100
1. (counter).

i <- i + 1
, . : " / ".
i < 1.

100. i = 100 ...,
"" (goto),
. <>
.

i <- 1
i<= 100

i <- i+1
_

, . _ (, . =, . loop, . boucle, =). .

-

69

.. ' .
2 . ......
.
. ,
.......
:

i 1 100
i
_

, . , . G
.
5. 1 + 2 + 3 + ... + 100.
, .
. ,
() .
, S i. :
S <- S + i
: " S
S
.
( , ).
:

70


S < 0
i 1 100
S < S +
_
// S //

i S.
, ' S ' i,
" "
,
. 1, 2, 3, 4 ... i 0 , 1 , 3, 6, 10 ... S.
( 100), // //
.
6. .
. !=1.2.3...(-1).
.
=0. , .
_
// //
< 1
i 1
<- * i
_
// //
_
. ! .
, .

71

7. 1 + 3 + 5 + ....+99.
,
4, 5 6
. . ...... :
i 1 99 _ 2
.
, ,
.

< = > 0

> = < 0

, . .

-10 10 _ 0.01
y < 2 - 5* + 6
, y
_

8. a b, a < b .
.,.
. . , .

_
a
b
_ a<b a>0 b>0

72


(data validation). . .
, , .


. .
,
.
. , , . , .
.

. y p a q ^ i
a A 2 a2, a(i,j) a[i,j] a,j .
,
" = 0 " " ...".
"" .

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

73

, , '
.
.
( " ") , (.
).Martin, Diagramming Techniques for Analysts and Programmers, Prentice Hall,
1985)
. , Keep. 2 .

3.1

( )
, . ,
( ).

76

3.2
, :

, , ,
.




.

3.3 -

, . ,
.

.

5.4

(3)

77

3.1 3.3

78

3.1
3.3 .

1,2, 3, 4
. 1
1 2 .



1.

1,90.
.

2.

3.

4.

5.



1:

2:

4:

5:

3:

79

3.4 3.6

LIFO

6 4 .

80



1.

' ' .

2.

- ^ /, .

3.

'
.

: , , . ,
. , : , , ,
, , .
, , . , , , , , , , , , . /, , , ;



1:

2:

3:

3 3! = 6. ,
, , , .
.

81

, , , , , ,
'

, , , , , ,

, , , , , ,

/
.

3.7 3.9

S2

',

'

' ' 6 3 4 .



1.

2.

3.

4.

,
.

5.

6.

7.

8.

83



1:

2:

3:

4:

5:

6: ( )

7:

8:

3.5

.
:

,
; .
, (heap) .


; .

3.6
,
.

3.7
1:

3.1

84

2:

3.1

3:

3.2
3.2
3.2
3.2
3.3
3.4
3.4

10: 3.5
11: 3.5
12: 3.8
13: ' ab,
a b .

/ / a , b //
b = 0
power < 1

(b MOD 2) = 0
power < (a*a, b DIV 2)

power < (a*a,b DIV 2)*a


_
_
// power //

14: 3.6
15: 3.6
16: 3.7
17: 3.7

85

3.8
>

1
table
. min age m a x a g e
, min max
.

// table//
min_age < table[1]
max_age < table[1]
min < 1
max < 1
i 2 300
table[i]<min_age
min_age < table[i]
min < i
_
table[i]>max_age
max_age < table [i]
max < i
_
_
min, min_age, max, max_age

2
( -1). , ( flag), -

86

. , , .
2
// table //
_
flag <
1 -1
table[i+l] < table[i]
(table[i+1], table[i])
flag <
_
_
_ flag=u
// table //
2

3
(push) (pop)
. , done, . , top . , stack size. item .

// top, item //
top<size
top < top+1
stack[top] < item
done

done <
_
// top, done //

87


// top //
top<=l
item < stack[top]
top < top-1
done <

done <
_
// item, top, done //

< = 1 . , .

4
. , done, . , rear front , queue size. item
.
__
// rear, item //
rear < size
rear
rear+1
queue[rear] < item
done <

done <
_
// rear, done //
__
__
// rear, item //

88

rear <= front


front < front+1
item < queue[front]
done <

done <
_
// item, rear, done //
__
rear< =front . '
.

5
.

.
3.7 2.

6
,
3.7. -1 10 , 10 .

>-
1
currency 5x2,
(
),
. ( ) nomismal nomisma2,

89

1 6.
. , posol
nomismal , poso2 nomisma2 .
_
// currency //
nomismal,nomisma2,posol
nomismal=6
poso2 - posol / currency [nornisma2, 2 ]
//scores//

poso2 < posol * currency[nomismal,1]


_
poso2
__

12
scores 5x5,
, . ,
5 sum. first (max).

// scores //
i 1 5
sum[i] < 0
_
i 1 5
j 1 5
sum[i] < sum[i]+ scores[i,j]
_
_
max < sum[l]
first
1
i 2 5

90

scores[i] > max


max < scores[i]
first <- i
_
_
// first //

3

straight insertion sort). '
.
(destination sequence) table[1 ], table[2],..., table[i-1 ]
(source sequence) table[i], ..., table[n]. , , .

.
.

// table //
i 2 n
temp < table[i]
table [0] < temp
j <r- i-1
temp<table[j]
table[j+l] < tabletj]
j <- j"l
_
table[j+1] temp

// table //
_

91

i=2

52

71

56

10

19

90

45

i=3

12: 52 ; 71

56

10

19

90

45

56

10

19

90

45

10

19

90

45

10

19

90

45

12

i=4

12

i=5

12 1 521 56

52

71

i=6

12

71

52 | 56

12

i=8

10

12

i=9

5 ; 10

12

CVJ

i=7

56

71

19

90

45

19

52

56

71

90

45

19

52

56

71

90

19

45

52

56

71

5 , 10 ,

12

45

90 ,

3.1. .

.
52,12, 71, 56, 5 , 1 0 , 1 9 , 90 45. . , . ""
.
. , 10 71, 56, 52,12 5, 10 5 12. 12
71

10.
( Pascal)
. '
table + 1 , , table[0], -

92


. ... .
,
.

4
, CD. CD, . , CD.

5
5.

3.9
.

3.9.1
:

&

-1 ,
. (straight selection
sort) .
, ' -

93

' '
. , ,
.
. . ,
, . , 5 ,
52. ,

.
.

=2

52

12

71

56

i-3

12

71

56

52

10

19

90

45

10

19

90

45

19

90

45

19

90

45

=4

10

71

56

52

12

&
=5

10

12

56

52

71

=6

10

12

19

52

71

56

90

45

i=7

10

12

19

45

71

56

90

52

i=8

10

12

19

45

52 j 56

90

71

i=9

10

12

19

45

52

56

90

71

10

12

19

45

52

56

71

90

&

3.2. .

94

3.9.2
(merging) . ,
(, ) .
.
y, n m , n + m >. , i, j k , y . .
y .
. .

// (), y(), n, m //
i < 1
j <- 1
k <- 1
*000 i <=n j <m
x[i] < y[j]
[k] <- x[i]
i <- i+1

[k] <- y [ j ]
j <- j+1
_
k <- k+1
_
i > n
t- j m
[k+t-j] < y[t]
_

t i n
[k+t-i] < [t]
_

95

// () / /

3.9.3
.
(pointer) , ( , , .)
. 3.3 , , info,
, , next,
.


3.3.

.
.

3.4.

__
// :
data:
q: //
q.info < data
q.next < p.next
p.next < q
__

96

data
3.5.

: , p.info
p.next
. ( q), .

P.Info

P.Next

3.6.

, . ,
, . ,
(' ' ).
__
// : ,
//
q <r- p. next
p.next < q.next
__
(dynamic),
. ,
,
. (-

97

Algol, Fortran, Cobol, .) ' ,



. '

.
, 3.7 ,
Info Next ( ). Info , Next . '' ,
Info, .
, .

info

10

26

15

23

37

17

33

next

3.7.

3.9.4
, , .
.
11
.
(graphs). :
.
(root) , -

98

. ,
. ( ) .

.
(father) ' .
(children) . . '
3.12
.
(degree) .
. n n- (n-ary) . (binary), (ternary) (quadtree).
(terminal
nodes leaves). (internal nonterminal nodes branches).
( ) 1.
(depth)
(height) . 3.12 3.
' ,
.

.
, .

. .
, (nil).
n + 1 , n
. 3.8
3.12 { ).

99

Left

Info

Right

3.8

>

. .
.

.
3.9.

3.9.

100

' ' '


'
.
', (
). . 3.9 35
Search-Node.
S e a r c h - N o d e

Root

//

//

< R o o t

<

n i l

. I n f o

= =

> . I n f o < . R i g h t
< . L e f t
_
_
_

//

//

S e a r c h - N o d e
, , .
Info .Left, .Right
.
:
,
. . ' .
. , . , .

.

>

707

(traverse). .
.
. (root)
.
(subtrees).
.
.
1.
2.
3. .
2 3
.


( 1, 2, 3), (preorder). 3.12
:


.
()
Preorder-Traversal.
Preorder-Traversal (R)
// R: //

102

R n i l
1

R . I n f o
1

Preorder-Traversal
'
=

R.Left

(A)

R.Right

1' r e r d e r - r a v e r s a ]

()

//

//

P r e o r d e r - T r a v e r s a l

. .


2, 3, 1

(postorder)
3.12 :

.


2, 1, 3

103

'

' (inorder) , ' :



'
.
' , ,
.

>-
1951 Jan Lukasiewicz '
'.
-
(polish notation), .

. :
1. +

4-

2. ( + ) .

. +

3. + ( . )

+ .

4. . + .

+ . .


.
< + + , +
. (-)
, (.. -)
(unary) (.. -).
.
- , + (-)
+ - .

104

' , (reverse polish


notation). :
1. +

2. ( + ) .

+ .

3. + ( . )

. +

4. . + .

. . +


. ..
. + . 3.10.

3.10


, (prefix) :
+ . .

, (postfix) :
. . +
, '
(infix) , :
. + .

105

' ', .. APL


FORTH. ' (.. Hewlett- Packard).
' .
. .
, :
A D D
.
MUL .
' ,
push . ,
ADD MUL ( ). . + ( +.) :
PUSH
PUSH
PUSH
MUL
ADD
.

3.9.5

,

106

.
,
. (graph). 4.1 ( )
. . , ,
- .
a, (adjacency matrix). , nxn, n . a,, 0 i j ,
ajj (weight)
, .
. (symmetric), ajj = aj,.

13

13

10

11

, ,
a^ = a^. ,
, .
,
. ,

1. , (binary) , 0 1.

107


' . , , ' '
.
Leoard Euler
" Koenigsberg", 1736. Koenigsberg Pregel,
2 7
. Koenigsberg
"
, ". Euler .



Kirchoff, 1847 -

4 3

,
Cayley

.
-

msSik

" 4 ",
4 ,
.
1850 1976.

108

3.10 3.2
( 51).
. ' ( ) ,
. ,
24 2 ,
,
,

.
24 , ( , , ..). ,

.
,
. ,
. .

4.1
' .

,
.

110

4.2
, ' :

,
' .

4.5 -
: " " " ".
"
" " ".
, .


. ,
. ,
( 3
) " " . ,
.

111

4.4

(2)

1

:


, .

. .
.

. . .

112

.
.

.
.

, . < 4.1 4.3 . 1 -4 .

.
1 2 .

'
2 3 , 1,
2 4 .



1.


, .

2.

3.

4.

() .

5.

6.

" " .

113

7.

8.

" " - .


9.

:
)
)
)
)

10.
:
)
)
)
)
11. :
)
)
)
)


1:

5:

9:

2:

6:

10:

3:

7:

11:

4:

8:

114

2

:


, .

. .

.
.

- .

115

, . 4.4 4.5 . 5-8 .

. 3 .

' 1 - 3, 5 6
.



1.

2.


, .

3.

, .


4.

5.

6.

, -

116


1:

4:

2:

5: '

3:

6:

4.5


,
.
.

4.6
,
.

4.7
1:

4.1 ( ).

2:

4.1 ( )

3:


:
( )
( ).

117

4.3 .
4.4 .
ppq)0 4.3 .

!.
. , ( ).
8:

, ab,
a b 3. ( )
" " ( ), (1, 2, ...,
b-1) " " b.


// a, b //
power [1] < 1
i 1 b
power[i] < power[i]*a
_
// power [ b]
3

//

.
power . , 2,
1 0, 2 1, 4
2, 16 3 ... .

16

256

" "
. 2 7 ,

118

4 2, 2 7 = 2 4 *2 2 *2 1 .
ab .

/./ a, h '
power[1] < a
<- 1
pow < 1
power < b
i <- i+1
pow < 2*pow
power[i] < power[i1]*power[i 1]
_
used < 0
result < 1
used < b
used+pow <= n
result < result*power[i]
used <- used+pow
pow < pow/2
_
i <- i-1
_
\\ result \\

4.8
>

1.

.
.

119


([1 ],M[pos]) [1] M[pos]:
_
// //
lowl < [1]
pos < 1
2 50
[] < lowl
lowl <- M[i]
pos < i
_
_
([1],M[pos])
low2 < [2]
3 50
[i] < low2 low2 < M[i]
_
// lowl , low2 //
_

2.

3.6
4.3 2 4 . .

3.

.
.

120

4.
' . ' , ( ).
.

>

1.
' 10 0 .
_
// number //
low < 0
high < 10
found < 0
number
low <= high
mid < (low + high)/2
Av mid < number
low < mid+1
_ mid > number
high < mid-1

found < 1
_
_
// found //
_

727

2.
4.3 2 4 .

3.
"

.
4.3 2 4 .

5.

. VATH
. 20 .

1000 :
SUM <- VATH [20]
i 19 1 -1
SUM+VATH[i] < 1000
SUM <- SUM+VATH[i]

stop
i-1

_
_

122

stop '
.

6.
5 .

4.9
.

4.9.1
.

(quicksort). ,
,
(bubblesort) . n
. /2
, .
. .
.
,
.
,
. , -

123

,
, . . , , , .,
. , .
_
// table, left, right //
right > left
i < left
j < right+1
pivot <r- table [left]
_
_
i <r- i+1
table[i] > pivot
_
j <- j-i
table[j] < pivot
Av i < j (table[i], table[j])
i > j
(table[left], table[j])
_(table, left, j-1)
_(table, j+1, right)
_
// table //
_
. (. 4.1).
, pivot = 52
. , 52.
71 ( i). ,
52, 45 (
j). 71 45, , 4.1 . -

124

52
52 . , 56
( ) 19 ( j), (. 4.1 ).
56 ( )
10 ( j). i > j,
. '
j. , 52
10, (. 4.1 ).

52

12

71

56

10

19

90

12

45

56

10

52

12

()

i
52

45

90

71

()

56

90

71

()

56

90

71

()

J'

19

45

19

10

10

12

45

19

52

4.1

-.
- ,
52. ,
"" . 52
-, 3
52. .
10

12

45

19

52

56

90

71

4.2
.

125

4.9.2
.
, ' .
(backtracking) , ,
, .
,
4.1 ( ) . , :
1)

,
( ),
^

2)

,
.
, "",
.


, . , ,
/. (),
, .

126

. , ,
, ' .
.
7 7 . , , . ,
,
.

4.3. 0 Hampton Court Palace

.
Hampton Court Palace, 3 .
4.3.
, 19 .

,
, .
,
.
4.4
4.3.

127

4.4

, , . " " (depth-first search) .


, , ,
, .

, .
n
. , mark, n /.
, . , , , .
AKB(k)
// a , //
mark(k)=
k
j 1 n
a(k,j)=l mark(j) = (j)
_
// //

128

, (1),
1, " "
mark(1)= . 2 1 ( a(1,2) = 1) (2).
2 ( 3"2)=),
2.
( 2) ,
(backtrack) 1. 3
(3), a(1,3) = 1 4 (4). 4 () 3, (5). , 1 , 2 , 3 , 4, 5, 6, 5, 7, 8, 9 , 1 0 , 1 1 , 1 2 , 1 3 ,
""
mark.
. , ( 2, 4, 6, 12 13).

. , ' ,
. ,
, ,
^

, ,
'
, .

, ,
, .

5.1

.
.

130

5.2
, :

5.3 -
:

. "" ()
.

5.4

(2)

131


, .


: ( )
.
: .
: (size) .
: .
:
.

132

: .

, : 5.1 5.2 . 1 -8 .

:
1 2 . '
1 2 1,
2 3 .



1.

2.

3.

4.

5.

6.

133


7.

8.

9.


. :
)

:
)

10

. , :
)

10.
:
)

754

11.
)

12. :
)


1:

7:

2:

8:

3:

9:

4:

10:

5:

11:

6:

12:

135


, .

. .

. .

.
.

, , 5.3 5.4 . 9-13 .

.
3 4 . '
3 4, 4 5.



1.

136

2.

f(n),
0(g(n)) c 0 , n>n0
: |f(n)|< c |g(n)|.

3.

().

4.

5.

O(logn).

6.

O(n)
n .


7.


,
.

8.

9.


I: 4:

7:

2:

5: 8:

3:

6: 9:

5.5


, . , -

137

, .
, , .

, , , . .
.

5.6
,
.

5.7
1.

5.1

2.

5.1

3.

5.1

4.

5.1

5.

5.1

6.

( )
. , , .

7.

5.2.

8.

5.2.

138

9.

5.3.

10. 5.3.
11. 5.3.2
12. 5.3.2 3 4 3
13. 5.4.

5.8
>

1.
1.

' . /2, ().

2.

/ .

1 =>=" 2

/=1

j= 1

/=1

, 0( 2 ).
3.

.
/2

/2

= = 2/2
,=1

j=1

1=1

, 0( 2 )
, , .

139

2:
donation ( 30 ),
.
sum.
_303
// donation //
sum < 0
i 1 30
sum < sum+donation[i]
_
sum
_30
. ().

3:
Fibonacci .
. ,
" ')'0
, n "n DIV 2". O(logn). 3 ( ),
.

4 ;
, ,
.
. 1960, / , .
.

140

>

1:
1.

= 100 .
, O(n).

2.

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

3.

.
(-1)/3, . O(n).

2:
( ) 1 1,
O(n).

3:
( 4.3 ) .
"KAT[mid]'(ONOMA",
. "" .
(high-low) . log(high-low). O(logn). 10 ,
.

4:
. , 0( 2 ). ,
.

101

2 .
(-1 ),
.

5:
19??. .
. , , ,
. ,
, .
.

5.9
: .
. n C .
, , lj < C 1 < i < n. n
,
.
n = 6 c = 1 , 50, 60, 30, 70,
50 40 .

. ! =
6! = 120, n . n ,
, (optimal).
, n , .. 1000, ( 1000!), -

142

(suboptimal)

, .
, 3. ,
1 5, 2 6 3 4 , 100 ,
.
,
. , first fit. , . ,
, .
, . .

:
.
:

. C.
, li < C 1 < i < n.

1,2,...,.

1,2,...,m.

i = 1. j = 1. =1.

i- j- , ,
6,
j = j + 1 .

j>X, X=j 4.

i = i +1.

i < n 4 8.

143

, 4
(1,3), (2,6), (4) (5) .
'
. first-fit 70% .

6.1
.

146

6.2
, :
.
.
.
.
.
.

.
.

6.3 -

, .
.
.
.
,
.

147

6.4
:
(1) .


, , .

1
.

.
.
.
.
.
4 .

.
.

148

.
.
.
.
.
Go .
.

.
.
- .
.
.

1, 2.
1 .
1
. ,
, ' '.
, .
,
. ,
.

109


.
1.

2.

3.

4.

.
.

5.

6.

Basic
.
.
.
. .

7.


:
,

8.

150


1.

2.

3.

4.

5.

6.

7.

, ,

8.

6.5
. ,

.
, , , .

6.6
,
.
:

http://devcentral.iftech.com/learning/tutorials/

151

Java, C + + , Visual
Basic.
http://www.comlab.ox.ac.uk/archive/occam.html
' , Occam.

6.7

6 .
1.

6.1

2.

6.2.1

3.

6.2.3

4.

6.2.3

5.

6.2.3

6.

6.3

7.

6.3

8.

6.4.1

9.

6.4.3

10. 6.4.3
11. 6.5
12. 6.7
13. 6.7
14. 6.7

152

6.8

>

1
2
3
4
1

5
_
_

2
' .
:

153

>

Pascal

154

2
2
3

4
_
5
_
6

7.1
,
.

156

7.2
, ' :

' .

' .

7.3 -



,
. ,

.
.
, .
, .

.

,
-

157

, .
. , Pascal
Basic, .

7
, .
.
, .
, ,
.
,
, ,
.

7
:
(1)

158

1

.


, , .

'

'


,

159

' 1 2 , 1
.


,
. , ,
.

1.

2.

3.

.
4.


) < - + 1
) < - + 1
) < - 1
) +1 <-

160

5.

' :
< - (5 + 4/2*2)*2-(3*2+5-3) 2+9/3-2
) -53
) -37
) -125
) - 4 5


=3.14

:,


<- * 2
'
...


1.

2.

3.

4.

5.

6.

, , ,

161

7.5
,
.
' :

http://pascal.miningco.com/
Pascal. .

http://www.angelfire.com/pa/rjolliff/
Pascal.

http://www.xs4all.nI/~dgb/delpascl.html#A_SITES
Pascal.

7.6


) 7 . :
1.

7.2

2.

7.3

3.

7.4

4.

7.7

5.

7.9

6.

7.9

7.

7.10

162

7.7

>

1.
1.

T<-2*TT*T_P(M/D)

2.

E<-(m*v*u A 2)/2

3.

F- :-T_P(F1 A 2 + F2 A 2+2*F1 *F2*ouv(cp))

4.

<-(-+_( 2-4**))/(2*)

2.
1.

2.

3.

4.

5.

6.

( )

3.

:, , , ,

'
, ,
<- (A-t +) /2
<-_(*(-)*(-)*(-))

_

163

'
.
, -, -, -
,
.

>

>

8.1


: , .

166

8.2

, :

, .

().

8.3


. 2.

Pascal
FOR Pascal . ( ) 1.
1,
for
( 3 )
. while, repeat if, case .

8.

167


(2) .

, .

().


, , .





: , ,

168


-
- -
-




8.1
1 .


1 2 . 3
1. 1
2.



1.

2.

3.

4.

10 20
( > 8 <20) (>10 = 10) .

169

.
5.

<-0
<-5
<-10
>10
>20
>10

<10

_
_

2*

. 0
. 10
. 5
. 20
6.

,
< ...
_

7.

170


AN ...0
<- _()

'


1 :
2 :
3 :
4 :
5:
6: , < -
7: > = ,


, .

171


, , .





-


_







8.2
.

4 5
. 4, Internet, . , 3.
5 1.



.

.

1.

2.

- .

3.

,
.

4.

.
5.

AC-10
0
I 1 5
AC-A-1
_

1Z?

. 10
. 0
. 2
.
6.


10.

<...
... 1 10 ...
- ... + 2
_

7.

100 200

<-.
...

_
<-+
<-+1
_


1 :
2 :
3 :
4 :
5 :
6 : 0, I, 2,
7 : 100, 0, >200

174

8.5

,
.
:

http://pascal.miningco.com/
Pascal. .

http://www.netalive.org/ckb/

Pascal Delphi, .

http://www.angelfire.com/pa/rjolliff/
Pascal.

http://www.xs4all.nI/~dgb/delpascl.html#A_SITES
Pascal.

8.6

8 .
1.

8.1

2.

8.1

3.

8.1.1

4.

8.1.1

5.

8.1.1

6.

8.1.2

7.

8.2

8.

8.2.2

9.

8.2.3

10. 8.2.3

8.7

>

1.
.

72.
.
>
'
_ >=(-2)
''

''
_
.

( = ' >15)

-/75

176

''
& <> '

''

<>

''

...'

AN <= 0 ()=0
' ...'1

<-( 2+5*)/(_()* ())


0_

3.

. .
2>700
' 1
' '
_ 2>500
' '
'
_ 02>4 00
' '
'
_
03 >500
' '
' '
_ 03 >300
' '
' '
_ 03 >250
' '
" '

177

4.

5 100. ''
.
I

<- 0

<-
I <=100
<- 3
<- +
I,
I <- 1+5
_

I <- 0
<- 0
_
<- 3
<- +
I,
I <- 1+5
_ I > 100

. .

5.

.

<- 0
0
<- 0
>
<-
0_
<
<-
0_
<- +

178

.
<- 0

_
<- 0
>
<-
_
<
<-
_
<- +

_ = 0
.
<-0
I 1 100
<- 0

>
<-
^
<
<-
_
<- +
_

>

>

179

8.8

. ,
, , , ..

. .


, .
. 1 10 ....
1 10, . . ,
.
" 1 10".
. , 1 10. ;
. . , ,
, ' .
, , .
. . -

180

, , , .




.
, .
, . Basic,
READ-DATA.
. 45 20 . m n .
.
.
.
,
.

9.1

182

9.2

, :

, .

9.3


.
.

.
,
.
3 4.

9.4


(2)

183

, .


, , .

184

9.1 .


1, 2 , 1
1 .



.

.

1)

2)

3)

4)

I.

.
5)

5
) :[5]
) :
) : [1 ], [2], [3], [4],[5]
) [5]:

6)

10

85

A)
I 1 10
<-+

)
I 1 10
<-+

)
I 1 10
+ [ I ]

)
I 1 10
<-[I]


7)

' ,
.

8)

0
I 1 30
[ ..]<-0


1.

2.

3.

4.

186

5.

6.

7.

8.

' .


, , .


.
.
.
.
.
.

187

9.3 . 3
.

3
4 , 2 4
5 .



.

.

1.

10
.

2.

3.

4.

.
5.

5X5

188

)
I 1 5
[I]

)
I 1 5
[I, I]

)
J 1 5
[J]

)
I 1 5
J 1
[I,J]
_


6.

7.

55
I 1 5
<-....
J 1 ...
<-...+
_

189


1.

2.

3.

4.

5.

6.

7.

0, 5,, l,j

9.5

,
.
:

http://pascal.miningco.com/
Pascal. .

http://www.netalive.org/ckb/
Pascal Delphi, .

http://www.angelfire.com/pa/rjolliff/
Pascal.

http://www.xs4all.nI/~dgb/delpascl.html#A_SITES
Pascal.

190

9.6

' ' 9 .
1.

9.1

2.

9.1

3.

9.1

4.

9.1

5.

9.1

6.

9.1

7.

9.1

8.

9.3

9.

9.1

10. 9.2
11. 9.4
12. 9.4
13. 9.4.

9.7

>-

1.

:[5]
I 1 5
A [I]<-

.
:[10]
I 1 10
[I]<-1-1
AO_

.
: [20]
I 1 20
[I]
_

.
:[10]
<-500
I 1 10
[ I]<-
<-/2

2.
<-[1]
<-1
<-[1]
<-1
I 2
[I] >
<-[I]
<-
_
[I] <
<-[I]
<-

191

192

_
_
[], []

3.
I 1 4
J 1 4
AN I O J
[I,J]<-0

[I,J]<-1
_
_

4.
I 1 5
<-[,3]
[ 1,3] <-[1,6]
[,6] <-
_

>-

>

10

10.1
.

194

10.2
, :

10.3 -
.

.
. ,
.

.

795

Pascal
Pascal , functions procedures,
.
, , .
(in parameters value parameters)

(in- out parameters variable parameters). To
, procedure difference (a,b:real;var dif:real).
,
.
Pascal .

Basic
QuickBASIC .
: QuickBASIC
.
.
.
QuickBASIC .
QuickBASIC , . ,
GOSUB.
. -

196

.
.

10.4
.
(2) .


, , .

197

10.1 - 1 0 . 6
.

198

1 2
, 1 1
. 3.



.

.

1.

2.

3.

.
4.


( = 1/2**).
) (,)
)
) (,):
)

5.

<-10
<-5
(,)
,

199

(,)
<-0
<-0
,

10 5

00
)

10 5
105

00
00

00
105

6.

7.


1)

2)

3)

4)

5)

6)

7)

200


, , .

.
.
.

10.7 . 2 .

3
4 .

201


'
.

.

1.

2.

3.

4!
3!, 2!, 1! 0!


4.


1.

2.

3.

4.

10.5
,
.
:

202

http://pascal.miningco.com/
Pascal. .

http://www.netalive.org/ckb/
Pascal Delphi, .

http://www.angelfire.com/pa/rjolliff/
Pascal.

http://www.xs4all.nI/~dgb/delpascl.html#A_SITES
Pascal.

10.6


10. :
1.

10.1

2.

10.2

3.

10.4

4.

10.5

5.

10.5.1

6.

10.5.2

7.

10.5.3

8.

10.5.3

9.

10.6

10. 10.7
11. 10.7

10.7

V

1.
)
)
)
)
)
)
)

2.
)
(2)
,2


' 2<- 2
_

)
(,,)
, ,

>
*-

03

204

<-
-

L_( , )
:,

<- l * 0.18

_ _

)
():
:

AN A mod 2 =0
<-

<-
_
_

3.
:

()<-*(-1)
(0)<-1

(4)

4*(3)

(3)

3*(2)

(2)

2*(1)

(1)

1 *(0)

()

205

(2)

2*1

(3)

3*2

(4)

6*4

:
I 1
l k o < - *

>

2*3

6*4

>

11

11.1
, .

208

11.2
, :

, , ,

11.3 -

:
1.

2.

.
, ,
.

3.

209

4.

5.

.

.
.

6.


.
,
.

7.


(trigger events)
(cascading
events).

8.


, .

9.


. ,
, , ,
.

10.

.
11.

.
.

210

12.
.

11

(3)

1

:

, , ,


, , ,

211

.
, ( 11.1 11.2)

, :

1 2.
:

1 .

1.
:

1.

.
.

212


' .



1.

' .

2.

3.

4.

5.

6.

.
7.

8.

9.

10.
.
11.
.

213

10

11

2

:

214


, , ,

,
( 11.3.1).

, :

3 4.
:

2 2 3 .

2, 7,
.

215

:
2 3.



1.

2.

3.

4.

5.

.
6.

7.

8.

216

3

:

' ,


, , ,

217


11.3.1. 11, 12 13 .

3.

2,
.

4 .

5 6.
:

4.

4,
. Visual Basic
Font FontBold, Fontltalic, FontSize,
ForeColor .
.

.

218



1.

' .

2.


' .

3.

4.

5.

.
6.

7.

8.

219

11.5

.
:

11.6

, .


1.

Timothy . Budd : An
Addison-Wesley, 1991.

Introduction

to

Object-Oriented

Programming,

2.

Peter Coad, Edward Yourdon, Edward Yourdan : Object Oriented Design,


Yourdon Press Computing Series, 1991.

3.

Steve Teixeira : Delphi 4 Developer's Guide (Developer's Guide Series), Sams,


Pacheco, 1998.

220

11.7
. .

:

11.3

11.2.2

11.1.1

11.1.4

11.2

10

11.1.2

12

11.5.1

13

11.6

11.8
>


.
, .

221

3.
. -.

>



. .

>



. .

12

12.1.
( ) , ,
.

224

12.2.
, :

, -

12.3. -

:

, .
. ,
.



.
.
. ,
, . ,
.


,
. ,
.

225

12.4.

(1)

1

1 :

( )
, qjiAiKO


, ,

(
)

( )

( )

( , )

226


,
,
12.3,
.

:
1
2
:
1
1 , .
:

1 2.

3 1.


, 3
.

.

.

227

1.

2.

3.

4.

GUI.

1.

2.

3.


1 :

2 :

A3 :

1:

2:

3:

4 :

12.5.

.

228

12.6.

,
.

http://mjmi.engin.umich.edu/Conf/N095/TALKS/TE14.1 .html

http://explorer.scrtec.org/aux/about/wlnterfacelnfo.shtml

http://www1 .viaweb.com/softpro/misc-user-interface-design.html

http://www1 .pitt.edu/~laudato/UI/

http://www.iol.ie/~nmurphy/hire.htm

http://www.acm.org/sigchi/chi97/proceedings/tutorial/dmh.htm

12.7.

1.


user interface, .

, (
). ,
, , .

2.

"
". .
. -

229

: , , .
3.

12.2.1.

4.

12.3.1.

5.

' ' . .
.

6.

12.4.2

7.

. :
, .

12.8.

:
, . ,
.


>-
1.

.

230

2.

.
. :

: ( ),

( ): (, , ).

>

1.
(project). .
, , (.. Visual Basic).

, .
:

231

>-
1.
.

.

" "

" "

" ".

2.
.

.

3.
,
1.

13

13.1
, .

234

13.2
, ' :

13.3 -

:
1.

, .

2.

.
.

3.

, , ,
.
.

235

13.4

(1)

1

:


, , ,

236


'
( 13.1 13.2) .

, :

1.

2.

3.

1, ' '
.
2,
.
3, , 13.4. .
:

1.

2.

1,
11. , .
2,

. Visual Basic

237

, .
.
:

1 2.

1, 2,
.
,
, , .
,
DiskNotReady.
.

.



1.

2.

3.

4.

238

5.

6.

.
7.

8.

(|>

9.

13.5

.
:

239


(beta-versions , , ..)

,
.

13.6

, .


1.

Lyn dupre : Bugs in Writing- Guide to Debugging Your Prose, Addison-Wesley


Pub Co, 1998

2.

Glenford J. Myers : Art of Software Testing, John Wiley & Sons, 1979

13.7
. .

:

13.4

13.3

200

13.8.
>
:
,
.
, .

3.
, .

3.

13.4 .

>-
,
.

.

>

,
.

.
2 ,
1.

14

74.7
,
.

242

14.2
, :

, , ,

. ,

, , , , , ,

14.3 -
,
.
.

,
. .

. .

243

14.4

(2)

1

' :


, ,

14.1. .

2 3 .

1, 3
4 .

244

1
2 , , .



1.

2.

3.

4.

5.

6.

. . 10
, 20.



1:

2:

3:

4:

5:

6:

'
:

245

.
' .
' ' , ' , , 7.
= 6 ,
.

2

:


, ,

14.2, 14.3. ,
. VTOC .

246

7 .

5 , .
2, 1
2.
4 2 3 .
4
.
.



1.

2.

VTOC .

3.

4.

, ' .

5.

, , , , .

247


.
.
.
(VTOC).



1: 2:
4: 5:

3:

248

0000

1000

3100

3000

5000

3300

14.5

.
:

. . .

,
, .

14.6

w w w . gold. net.au/'''other/techical/delphi-pascal/pascal-ArabicToRoman. html

249

http/hackensackhigh.org/roman.html

14.7 .
14 .

14.8 .
>

1.
. . :

!!

D<-0

d=0

1 7
AN Hqpfpa=day()
D<- L
<-8
_
_

day . d .
"". - 1 0 , : 10 ; -

250

3 .
.
7 , .
, , .

2.
3, 5, 6 7.
.

<-
mod 4 = 0
<-
mod 100 = 0
<-
mod 400 = 0
<-
_
_

3.
: > , > , > .
,
3 .
>
temp <-
<-
p<-temp

251

4.
3 . ,

. .

>

1.
(//) (.
). . 7 . 1 . ' 4 .

2.
(') ,
21 ' ''.

3.
, 3,4, 5, 6
.

252

' '

' '

'

'

'

4 .
, '. 4 5 .

4.
2 3" . VTOC.

>-
1.
1 .

2.
1 .

3.
.

253

31

59

90

120

151

181

212

243

10

273

11

304

12

334

20/5/

( 5 ) + 2 0 = 1 2 0 + 2 0 = 1 4 0 .


30 .

-1

10

11

12

2 5 4

20/5/ (5-1)*30 + ( 5 ) + 2 0 = 4 * 3 0 + 0 + 2 0 = 1 2 0 + 2 0 = 1 4 0 ' .


1/1/1,
' .
.

4.
.

5.
12 (
4000).
, , .
.
. . .

, '
.

. ,
, .

.
.
. . , .

.
. (program files), (text files), (binary files)
(executable) (data files).
. -

256

(directories).

1. -
(character) .
byte ' .
(field)
. , . (
) ( . ). , .
, , .
(logical record) .
.. (record) .

(layout).

.
(file). . ,
.
. (key)
.
.
(. , , ) , .
, ,

257

.
( - doublicate keys). .. ,
, .
,
(primary key) (secondary alternate
keys). , .

2.
:
1.

(master files). .
(.. , , , ) ( , ). : ,
, ..

2.

(transaction files).
, .
. .

3.

(index files).
- .

4.

(auxiliary files). .. , , ..

5.

(work) (intemediary).
.

258

6.

(historical files). .

7.

(backup files). , . . .

5.
:

(retrieval) . . ,
.


, ,
.
(query). , . : " 1 6,
,
1 200.000 .".

(updating). ( / ). : (addition) , (deletion)


(modification) .
-

259

.
.
( )
( ).
,
.

,
( ). .

(sorting).
.

(merging).
.

, sort-merge
.
(append) , , . (copy)
,
(back-up), ..
.

.
.
.
.

260

.
.
Update-File


=0 :




"--"

- ""


- ""



- ()

Update-File
-

261

, . "" ,
, . .
, .
, .. Enter ( ). ,
, .
.
, .
.

4.

:

.
.. , , .
.

, . .
(.. byte).
.

.
.
.
,

262

.
(line feed-carriage return)
. (EOF-End Of File)
.
,
.
)

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

. , , .

,
.


.
.
(binary)
1
byte.

263

5.

.
. ,
, , , ...
. . ,
, , , . .
(fragmentation). ,
( ).
. . , -
.
, ,
.
. ( ) .
, ,

(buffer).
.
.
. () , ' .

264

. '
, . .
(blocking) . (blocks)
.

(blocking factor).
, (inter record gap-IRG). To

. 3/4 .

6.

(, , )
,
.
.
. :

( - interactive, - transaction
processing, - batch)

(, , )

265

- - : , .

7.
.
, (access methods)
/
.

, . .
, (sequential) (random).
,
.
. , , .
. ,
.
, . .
( ), , . ,

266

. ,
.
:
)

1 (seek time),

12 .

1 +12. 12 , 1 , .
1 ,
,
. random. " ". .
.

8. (sequential organization).
, - , -1 .
( .
, (key) . ,
.
, /2 , .

267

. .
, ( .. ).
(text
files).
""
.. . ( ' ), .
.
, , .

8.1
. .
"" .
, .
, , .
(validation) . ,
, ,
:

268

1,
().
2, ,
()
3, .
. , (matching) :
, .
, (=1), .
=2 , (=3).
, . .
,
(merging)
.

8.2
Turbo Pascal
(text files) Turbo Pascal. -

269

.
- (end of line, eoln)
CR LF. -
(end-of-file, eof).
Input Output .

.

Turbo Pascal, Input, Output, :

: ,
. Input, Output.
Program

: , ,
.
text.
var
_ :tcxt

:
. Turbo Pascal assign.
Assign (

, -)

: , reset. reset .
Reset (

270

: rewrite
append. rewrite
append .
Rewrite (

(_)

: read, readln.
(,

: write,
writeln.
\/( , )

: close.

eoln eof.
eoln - True. eof .
Eoln (
Eof (

)
)

QuickBASIC

. CR LF,
EOF (Ascii 26).

271

OPEN
. :
OPEN _ [FOR ] AS [#]_lou
INPUT, OUTPUT APPEND .
PRINT WRITE :
PRINT #_lou, _
. WRITE ,
.
INPUT :
INPUT #l_, _
( ) INPUT , .

8.3
1.

Turbo Pascal
program filesl(input,output);
uses crt;
var
cod:integer;
per:string[20];
tm:integer;
g:real;
stock:Text;
begin
clrscr;
assign(stock,'stock.dat');
rewrite(stock);
write( l :');

272

readln(cod);
while cod>0 do
begin
write('
readln(per);
write (' :');
readln(tm);
write(' =');
readln(g) ;
writeIn (stock,cod:3,per:20,tm:4,g:6);
clrscr;
write( :');
readln(cod);
end;
close (stock);
end.
Quick Basic


OPEN "STOCK.DAT" FOR OUTPUT AS #1
INPUT " =",cod$
IF cod$="" THEN EXIT DO
INPUT " =",per$
INPUT " =",tm
INPUT "
=",g!
PRINT#1,cod$;";per$;",";tm;",";g!
LOOP
CLOSE
END
2.

To (dump)
.

Turbo Pascal
program files2(input,output);
uses crt;
var

273

:char;
grami:string[80];
stock:Text;
begin
clrscr;
assign(stock,'stock.dat');
reset(stock);
while not eof(stock) do
begin
readln(stock,grami);
writeln(grami);
end;
close(stock);
write(' ...');
:=readkey;
end.

Quick Basic


OPEN "STOCK.DAT" FOR INPUT AS #1
CLS
WHILE NOT EOF(1)
LINE INPUT#1, $
PRINT $
WEND
CLOSE
END

( ' readln
LINE INPUT ' . ).
3.

274

Turbo Pascal
program files3(input,output,1st,stock);
uses crt;
const.

max_crt=22;
max_prn=63;
var
xx:char;

cod,lines,choice,max_lines,pages:integer;
per:string[20];
tm:integer;
g:real;
stock,1st:Text;
procedure PRINT_TITLES(var lst:text;var lines,pages:integer),
begin
writeln (1st,'

')
lines:=0;
pages:=pages+l
end;
begin
clrscr;
assign(stock,'stock.dat');
reset(stock);
clrscr;
pages:=0;
writeln ( ' ');
writeln;
1.00');
writeln ('
writeln
2.');
repeat
gotoxy(5,5); write('En:');readln(choice);
until (choice=l) or (choice=2);
if choice=l then
begin
assign (1st,'con');

max_lines:=max_crt
end
else
begin
assign(1st,'LPT1');
max_lines:=max_prn;
end;
rewrite(1st);
print_titles(1st,lines,pages);
while not eof (stock) do
begin
readln(stock,cod,per,tm,g);
if linesmax_lines then
begin
writeln (1st,': ',pages:2);
if choice=l then
begin
write( ..');
xx:=readkey;
clrscr; { }
end
else
writeln(1st,chr(12)); { )
print_titles(1st,lines,pages);
end;
writeln (1st, cod: 5,' \per:20,' \tm:4,' ^:10:2);
lines:=lines+l;
end;
writeln (1st,': x,pages:2);
write(' . ..');
xx:=readkey;
close (stock); close(1st);
end.

275

276

Quick Basic


k$ =
CLS
page = 1: lines = 100
PRINT " "
PRINT

PRINT "1. "


PRINT "2. "
LOCATE 7, 1: PRINT " :
DO WHILE VAL(k$) 1 OR VAL(k$) 2
k$ = INKEY$: LOCATE 7, 11, 1: PRINT k$;
LOOP
k = VAL(k$)
IF k = 1 THEN
OPEN "0", #3, "SCRN:": maxl = 22
ELSE
OPEN "0", #3, "LPT1:": maxl = 66
END IF
OPEN "I", #1, "STOCK.DAT"

Printing
WHILE NOT EOF(1)
GOSUB ReadNextRecord
GOSUB PrintOneLine
WEND
CLOSE : END
ReadNextRecord:
INPUT #1, cod$, per$, tm, q!
RETURN
PrintOneLine:
IF lines maxl THEN GOSUB PrintTitle
PRINT #3, cod$; "
per$; TAB(30);
PRINT #3, USING "#####"; tm;
PRINT #3, USING
lines = lines + 1
RETURN
PrintTitle:
IF k = 1 THEN
GOSUB Press: CLS

277

ELSE
PRINT #3, CHR$(12);
END IF
PRINT #3, ".
MON. ";
PRINT #3, TAB(70); ":"; page
PRINT #3, STRING$(79, "-")
page = page + 1: lines = 3
RETURN
Press:
LOCATE 24, 1
PRINT " ...";
w$ = INPUT$(1): RETURN
OPEN ' . # 3
.
, PRINT # 3
PRINT. ,
LPRINT.
. lines 100, . .
4.

" "

Turbo Pascal
program files4(input, output, myfile);
uses crt;
Var
Pinakas:array[1..50,1..50] of integer;
i,j,,:integer;
myfile:text;
begin
clrscr;
assign (myfile,'ARXEIO.DAT');
reset (myfile);

278

{ }
readln (myfile, , );
for i:=l to do
begin
for j:=1 to do
read(myfile,pinakas[i, j ]) ;
readln (myfile);
end;
{ TOY }
for i:=l to do
begin
for j:=1 to do
write (pinakas[i,j], '
writeln
end;
readln;
end.

);

Quick Basic
DIM a (20,
OPEN "I",
INPUT #1,
FOR i = 1
FOR j

20)
#1, "data.dat"
m,
TO m
= 1 TO

INPUT #1, a (i, j)


NEXT j
NEXT i
CLOSE : END
' '
a.
( )
. ' '
( editor),
.

279

.

.
5.

Turbo Pascal
program files5(input, output, myfile);
uses crt;
const { TOY }
N=4 ;
M=5;
Var
Pinakas:array[1..M,1..N] of integer;
i,j,MM,NN:integer;
myfile:text;
begin
assign (myfile,'ARXEIO.DAT');
rewrite (myfile);
{ }
for i:=1 to do
for j:=1 to do
begin
write ('PINAKAS[\ I:2,',',J:2,']
readln(pinakas[i,j]);
end;
{ }
write(myfile,:4,:4);
for i:=l to do
begin
writeln(myfile);
for j:=1 to do
write(myfile,pinakas[i,j]:5);
end;

);

280

close (myfile);
writeln
readln
end.

( ');

Quick Basic
* Save table
OPEN "0",#1,"ARRAY.DAT"
PRINT #1,m,n
FOR i=l TO m
FOR j =1 TO n
PRINT #1,a(i,j);
NEXT j
PRINT #1
NEXT i
CLOSE:RETURN
'
-