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

32.973.2-018.

17
004.43(075)
93

93

. , .
. 2- . .: , 2011. 320 .:
.
ISBN 978-5-4237-0170-3
, , .
,
. , , , .
,
.
, .
, , , , . .
32.973.2-018.17
004.43(075)

.
.
, , , . , , , .

ISBN 978-5-4237-0170-3

, 2011


. . . . . . . . . . . . . . . . 15
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

1.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.1. . . . . . . . . . . . . . . . . .
1.2. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
1.3. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

18
19
20
28
34
34

2. . . . . 36
2.1. : . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Integer. . . . . . .
Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Integer . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2. . . . . . . . . . . . . . . .
(real) . . . . . . . . . . . . .
. . . . . . . . . . . . .

37
38
38
40
42
43
45
45
46

6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
real . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
2.4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5. ? . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

46
47
48
50
51
51
52
53
56
57
57
61
62
64
64

3. . . . . . . . . . . . . 66
3.1. . . . . . . . . . . . . . . . . . . . .
ASCII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Char . . . . . . . . . . . . .
3.2. Char ! . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

67
67
68
70
71
72

4. . . . . . . . . . . . . . . . 73
4.1. ! . . . . . . . . . . . . . . .
(Boolean) . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
- . . . . . . . . . . . . . . . . . . . . . .
4.2. () . . . . . . . . . . . . . . . . . . . . .
() . . . . . . . . . . . . . . . . . . .
() . . . . . . . . . . . . . . . . . . . . .
( 2) . . . . . . . . . . . .
() . . . . . . . . . . . . . . . . . . . . . . .

74
75
75
76
76
76
77
77
78


7
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

78
80
81
81

5.
. . . . . . . . . . . . . . . . . . . . . . . . . 82
5.1. . . . . . . . . . . . .
if . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3. ( case) . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

83
84
86
88
92
96
96

6. . . . . . 98
6.1. for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
for 100
for 101
6.2. . . . . . . . . . . . . . . . . . . . . 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

7. . . . . . . . . . . . . . . . . . . . . . 110
7.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . .
. . . . . . . . . . .
7.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
repeat while . . . . . . . . . . . . . . . . . . .
while repeat . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

111
111
112
115
119
120
120
123
129
129

8.
8.1. . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .

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

. . . . . . . . . . . . . . . . . . . .
8.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

. . . . . . . . .
. .
8.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

131
132
133
133
134
137
140
144
148
148
149
150
154
156
157

9. .
.
. . . . . . . . . . . . . . . . . . . . . . . . 158
9.1. . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . .
9.2. :
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

159
160
167
168
169

10. . . . 170
10.1. : String . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
10.2.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

171
171
172
173


9

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

11. . . . . 176
11.1.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
11.2. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

177
177
179
179
181
183
184

12. :
. . . . . . . . . . . . . . . . . . . . . . . . 185
12.1. . . . . . . . . . . . . . . . . . . . 186
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
12.2.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
. . . . . . . . 192
. . . . . . . . . . . 192
. . . . . . . . . . . . . . . 196
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

13. . Graph
13.1. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . .
13.2. Graph . . . .
Graph . . . . . . . . . . . . .
Graph . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

199
200
200
201
203
203
205
206
207

10

14. ,
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
14.1.
goto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14.2., . . . . .
break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

210
213
213
214
215
215

15. : . . . . . . . . . . . . . 216
15.1. record . . . . . . . . . . . . . . . . . . . . . . .
15.2. . . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
with . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

218
220
220
220
221
223
224
225
225

16. . . . . . . . . . . . . . 226
16.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
16.4. . . . . . . . . . . . . . . . . . . .
New Dispose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .
GetMem FreeMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
,
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

227
229
230
230
232
232
233
235
236
237
238
241
242


11

17. . . . . . 244
17.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.2. . . . . .
(Push) . . . . . . . . . . . . . . . . . . . . .
(Pop) . . . . . . . . . . . . . . . . . . . .
(StackIsEmpty) . . . . . . . . . . . . . .
17.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

245
247
248
251
252
253
255
256
256

18. .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
18.1. . . . . . . . . . . .
18.2. . . . . . . . . . . . . . . . . . . . . .
(EnQueue) . . . . . . . . . . . . . .
(DeQueue) . . . . . . . . . . . . .
(QueueIsEmpty) . . . . . . . . . .
18.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

259
261
261
263
264
264
267
269
269

19. .
. . . . . . . . . . . . . . . . . . 270
19.1. . . . . . . . . . . .
19.2. . . .
. . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
19.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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

271
272
272
273
275
276
278
280
280

12

20. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
20.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.3. . . . . . . . . . . . . .
20.4.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.5.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

282
285
287
288
289
291
291

1. - . . . . . . . . . . . . . 292
2. . . . . . . . . . . . . . . . . . . . . . . . . 295
Integer. . . . . . . . . . . . . . . . . . . . . . . . .
Real. . . . . . . . . . . . . . . .
Real. . . . . . . . . . . . . . . . . . . . . . . . . .
Char. . . . . . . . . . . . . . . . . . . . . . . . . . .
Boolean. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Boolean. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
If. . Min/max/ . . . . . . . . . . . . . . . . . . . . . .
If. . . . . . . . . . . . . . . . . . . . .
For. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
For. . . . . . . . . . . . . . . . . . . . . . . . . . .
For. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
While-Repeat. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
While-Repeat. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. , , / . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

296
296
297
298
298
299
300
300
300
301
302
302
303
303
304
305
305
306
307
307
307
308
309


13
. I . . . . . . . . . . . . . . . . . . . . . . . . .
. II . . . . . . . . . . . . . . . . . . . . . . . .
. III . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

309
310
310
311
312
313





. ,
, , , .

.

.

, 58 .
.
( ).

, , ...
,
.


? , , .
. ,
, , . .

. .
,
, , , .
. 1979
.
, .
, . .
. ,

!
,
.
!


, ,
comp@piter.com ( , ).
!
, ,
http:/www.piter.com/download.
http:/www.piter.com

,
. . , ,
: , ,
!

1.1.

-.
.
.

,
{}.
1.1.
program First; { .
program ;
First ,
.

.


";".
.
begin }
begin
{

1.2. 19
.
, ,
;

;

.}
write (', '); {
}
{
!
,
"ln" writeln
"line" - "" }
writeln ('!');
writeln (' ') {
,
.
, end
}
end.
{ end
;
}

, ,
.
. ,
program ,
.
writeln ,
.

1.2.

, Turbo Pascal.
7. ,
. ,
.

20 1.
, 7
. !
,
() ,
.


1. ( Edit).

.
2. ( Compile).
.
1.
3. ( Build).
1,
.
1.
4. ( Run).
1.

Turbo Pascal.

(), - .
, . 9-
.
,

- . ,
(, write writeln)
Turbo

Pascal
. - .
() .
, , . .

1.2. 21

Edit ()

Compile ()

Build ()

Run ()

. 1.1.

22 1.

.
1. Turbo Pascal
Turbo Pascal,
, turbo.exe bp.exe ( Turbo Pascal)
Windows (4).

Turbo Pascal
:
( );
( );
( ).
!

F10 (
).
Esc
.

Turbo Pascal Windows.


, Turbo Pascal Windows,
(, ). Turbo Pascal
MS-DOS,
.
-, MS-DOS
. ,
60 ,

85. Windows
.
Turbo Pascal ( Alt+Enter)
.
-, MS-DOS- Windows.

1.2. 23

: Turbo Pascal
Ctrl+Shift, Ctrl+Shift.
.
MS-DOS .
-, MS-DOS
Windows. Turbo Pascal ,
, . Turbo Pascal
Turbo Pascal Exit File
Alt+X .
2. Edit
( F10).
File
(, ).
Enter.

File:
New
Open
Save
Save as
Save all
-------------------Change dir
Print
Printer setup
DOS shell
Exit

F3
F2
------

Alt+X

, ,
.
New
(, ')
Enter.

, NONAME00.PAS.
,
(, , ). ,

24 1.
, NONAME01.PAS.
.
, Alt,
, .
F6.
, . , .
Enter. :
1.2.
program First;
begin
write(', ');
writeln('!');
writeln(' ')
end.

Turbo Pascal ,
: .

.

. , !

(.1.1).
1.1. Turbo Pascal

Enter

Home

End

1.2. 25

Ctrl+Home

Ctrl+End

Insert (Ins)
Insert (Ins)

Delete (Del)

Backspace (Bs)

, , ,

Page Up (PgUp)

Page Dn (PgDn)

1. 1-
2. Delete

Ctrl+Y

(PgUp, PgDn, Ins, Del . .)


Num Lock.
Edit. , ,
.
, Shift,
.
, Win
dows , , , .
Turbo Pascal, Windows, , , .
.
Windows
(.1.2).

26 1.
1.2.
Turbo Pascal

Ctrl+Delete

(Cut)

Shift+Delete

(Copy)

Ctrl+Insert

(Paste)

Shift+Insert

1.1. ( Turbo Pascal) ,


! 80
20 4 .
. .
write , (
). 3

, .
(writeln).
19. begin end !
3.
File ( Alt+F).
File Save as.... (Turbo
Pascal Save File As.)
Tab ( ).
Save file as ,
, MY.PAS, Enter (
.pas ).

Files , Save file as.


Files Enter,
Save file as. OK
. Cancel
. Help .

1.2. 27


F2 (Save).


MS
-
DOS
, MS-DOS.
8- , .
4.
Compile (Alt+C).
Compile Compile.
Enter.

, : Compilation successful: press any key


( : ).
, . ,
. ,
F1. Esc .

,

Ctrl+F1.

Alt+F9.

5.
( Build)
.
Run (Alt+R).
Run Run,
Enter.

28 1.

Ctrl+F9.
, Run .
6.
Alt+F5
.
.
Turbo Pascal .
, .

7. Turbo Pascal
Alt+X.

Turbo

Pascal

Alt+X.
, , ,
. Turbo Pascal
File Exit. ,
Turbo Pascal
Windows , .
, , .
1.2. ,
:

Write
Writeln!

1.3.

, ,
. ,
?

1.3. 29

Turbo Pascal
. Crt (
, -
,
).
,
IBM- (
). (), ,
,
.
Crt
.
, Turbo Pascal . ,
, , .
25 80 (. 1.2).
2 x y,
x , y .
, 25, , 1-
80. (1,1), (80,1), (1,25).
C 16 ,
0 15. . ,
, , red Turbo Pascal
Ctrl+F1 .
1
1

25

80

(1,1)

(80,1)

(1,25)
y

. 1.2. CRT

30 1.
:
1.3. Crt
program Second;
{ Crt
.

( CRT),

.
uses.
.
";"}
uses Crt;
{ Crt - .
";" }
{ }
begin
TextBackGround (3);
{
.


"3"
- .

: black, red,
green, blue, magenta, cyan, }
ClrScr;
{ .

ClrScr,
- }
TextColor (14);

{
.

.
.
:
TextColor
,
!
,

}

1.3. 31
GoToXY (40,10);

{

X=40, Y=10 }

Writeln(' !!!');
{ 10 ,
40 }
Delay (1000)

end.

{
1000 }
{
Delay(1)
, 1/1000 .

}
{ }

1.3. , .
.

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

.
, .

.
() 1.3.
1.4. ,
red, green, blue, yellow
( 4 , ):

32 1.
+-----------------+-------------------+
|
|
+
|
green
|
blue
+
|
|
+
+-----------------+-------------------+
|
|
+
|
yellow
|
red
+
|
|
+
+-----------------+-------------------+

1.5. , .
.
.
1.

A. Crt;

2. B. TextBackGround(red);

ClrScr;
3.

C. Write(Happy New Year);

4.

D. GoToXY(78,1);

5. E. TextColor(red);
Happy New Year c

6. F. TextColor(12); Write
(Hello);
7.

G. GoToXY(1,23);

8. H. W r i t e l n ( H a p p y
Happy New Year Year);

New

9. Turbo Pascal - I. Begin end



10.

J. TextBackGround(red);

11. Hello

K. ClrScr;

12. Hello 12

L. GotoXY(35,12); Write
(Hello);

: 1K, 2G, 3J, 4B, 5H, 6D, 7E, 8C, 9A, 10I, 11L,
12F.

1.3. 33

. 1.3.

34 1.

, , , Trubo Pascal.
Turbo Pascal.

1.
. ,
.
2.
.
Begin End. Begin End
.
3. write
writeln.
4. Turbo-

. uses.
5. Crt.
(ClrScr),
(GotoXY), (TextColor) (TextBack
Ground).


1. ?
2. ?
3. Turbo Pascal? Turbo Pascal?
Turbo Pascal?
4. write writeln?
?

35

5. ,
?
?
6. ?
7. ?
.
8. ?
?
9. ?

, .
, (
). :
.

.

2.1. :
, , - . , , .
(), ,
(.2.1). .

A
C
Sum

00153
00154
00155
00156
00158

15
8
7

. 2.1.

38 2.


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

() ,
,
(). ,
. Turbo Pascal7.1
63.

Integer. .

. .

Integer.

!
2.1.
Program Product;
{ .
var ( variable ) }
var
A,B,C: integer;

{ ;

2.1. : 39
:
integer }
Begin

{ }

A:=5;

{ .
,
() A
5.
A=5 !!! }

writeln(A);

{
A.
A ! }

writeln('A');

{ A }

A:=A+1;

{ A ,
,
1 }

B:=7;
C:=A*B;

{ * }

writeln('Product=',C)
end.

{ C
}

{ }

:
5
A
Product=42
!

. .

. .
,
.

40 2.
,
:=.

Integer
, .
2.2.
Program Action;
var
A,B,C: integer;
begin
A:=17;
B:=3;
{ : }
C:=A*B;
writeln('17 * 3=',C);
{ : }
C:=A div B; writeln('17 div 3=',C);
{ : }
C:=A mod B; writeln('17 mod 3=',C);
{ : }
C:=A+B;
writeln('17 + 3=',C);
{ : }
C:=A-B;
writeln('17 - 3=',C)
end.

:
17
17
17
17
17

* 3=51
div 3=5
mod 3=2
+ 3=20
3=14

2.1. : 41

div mod.
2- (.2.2).

. 2.2.

: ,
! ,
( , ) (
, ). , ,
. mod. , ,
. div.
, 2- :
5
6
40
3

div
div
div
div

2=2;
2=3;
6=5;
5=0;

5
6
40
3

mod
mod
mod
mod

2=1;
2=0;
6=4;
5=3.

div mod
, ( ). . ,
, :
(10) div 3=3; (10) mod 3=1;
(3) div 5=0; (3) mod 5=3.

2.1. 3 A, B, C.
.
(.2.3).
.
2.2. ( ). .

42 2.

. 2.3. - 2.1

Integer
.
.
2.3.
Program Infunct;
var
A,B,C: integer;
begin
A:=-2;

2.1. : 43
{ Abs (X)
X, X }
B:=Abs(A); writeln('Abs(-2)=',B);
{ Sqr (X) X }
C:=Sqr(B); writeln('Sqr(B)=',C);
C:=Sqr(B+B); writeln('Sqr(B+B)=',C)
end.

:
Abs(2)=2
Sqr(B)=4
Sqr(B+B)=16

2.3. |3954842|.
2.4. A B ( , , :=20; :=13).
.
! :=, 20
13!
(.2.4).

. 2.4.
.

2.5. 4
. .



. , -

44 2.
: 0 1, .
(
). , , (. .2.1).
8, 1.
8.
integer
2=16.
, , .
:
0 ;
1 .
15
(.2.5).

. 2.5. ()
integer

15 215 .
15 , 15

. , (2151)
. (+)
, integer
215+2151, 32768 +32767.
integer
(.2.1).
2.6.,
,
:
)x5;
)x6;
)x8;
)x9;
)x10.

2.2. 45
2.1. Turbo Pascal

()

byte

0 281

0255

word

0 2 1

065535

2 2 1

128127

integer

2 2 1 32768 32767

longint

231 2311 2147483648


2147483647

shortint

16

15

15

2.2.

, , ?

(real)
.
real .
2.4. real
Program Optel;
var
A,B,C: real;
begin
A:=3.5;
B:=7.6;
C:=A+B;
writeln('=',C)
end.

:
=1.1100000000E+01

46 2.


2.4
, .
:
1. .
:
0,7 0.7 .7
2,1 2.1
2. : ,
, 10
.
:
2700=2,7103. 10 E,
: 2.7E3;
0,002=2103 2E3.


2.5.
program Operation;
var
A,B,C: real;
begin
A:=17.3;
B:=3.4;
C:=A*B; writeln('A*B=',C);
{ / }
C:=A/B; writeln('A/B=',C);
C:=A+B; writeln('A+B=',C);
C:=A-B; writeln('A-B=',C)
end.

:
A*B= 5.8820000000E+01
A/B= 5.0882352941E+00

2.2. 47
A+B= 2.0700000000E+01
A-B= 1.3900000000E+01

,
. / .
2.7. :
7.478937 - 89.2456
# 76.2833 .
883.5995 + 618.332

real
2.6.
Program AllFunc;
var
A,B: real;
begin
A:=2.0;
B:=Sqr(A); writeln('Sqr(2.0)=',B);
B:=Abs(-A); writeln('Abs(-2.0)=',B);
B:=Sqrt (A);
{ }
writeln('Sqrt(2)=',B);
B:=Sin (A);

{ }

{
, .
"B" 6 .
3
}
writeln('Sin(2)=',B:6:3);
B:=Cos (A);
{ }
writeln('Cos(2)=',B:6:3);
B:=Arctan (A);
{ }
writeln('Arctan(2)=',B);
B:=Ln (A);
{ }

48 2.
writeln('Ln(2)=',B);
B:=Exp (A);
{ e A }
writeln('Exp(2)=',B);
B:=Pi;
{ }
writeln('Pi=',B)
end.

:
Sqr(2.0)= 4.0000000000E+00
Abs(2.0)= 2.0000000000E+00
Sqrt(2)= 1.4142135624E+00
Sin(2)= 0.909
Cos(2)=0.416
Arctan(2)= 1.1071487178E+00
Ln(2)= 6.9314718056E01
Exp(2)= 7.3890560989E+00
Pi= 3.1415926536E+00

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


, . :
tg x =

sin x
,
cos x

ctg x =

cos x
,
sin x

log y x =

ln x
,
ln y

x y = e y ln x .

, (2 x + 3)1+ cos x ,
:
exp( (1+cos(x)) * ln(2*x+3) )

2.2. 49

,
.
x +1
,
, x+1/2x,
2x
. -, ,
, ,
: (x+1). -, ,
2x. ,
. ,
: (x+1)/2*x.
. ,
. ,
,
x.
(x+1)/(2*x), , , : (x+1)/2/x.
, . :
2 , 2,
x!
!

.
( Pi, ),
. ,
,
. , sin2x sin(2*x).
2.8. . .
(.2.6.).
.
2.9. :
3, 15
2
m + 53, 7 .
arctg c sin
6, 1

50 2.

A, B, C

. 2.6. 2.8




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

. 2.7. ()
real

8 , , . .
.

2.3. 51
2.2. Turbo Pascal

()

(single)

1045 1038

7 8

(real)

10

(double)

10

(extended)

10

10

39

10

324

38

10

4932

308

10

4932

11 12
15 16
19 20

2.3.


. ?


2.7.

Program Mix;
var
N,K: integer;
A,B: real;
begin
N:=4;
A:=3.6;
B:=N;

{ real
}

writeln('B=',B);
{ integer
! -
real integer,

52 2.
, .
: }
N:=Trunc(A);

{ Trunc(X)
X,
, }
writeln('Trunc(3.6)=',N);
{ Round(X)
}

K:=Round(A);

writeln('Round(3.6)=',K)
end.

:
B:= 4.0000000000E+00
Trunc(3.6)=3
Round(3.6)=4

:
integer 2, real
6. , integer real ( ,
). real integer
. - ,
, . 2: trunc round.
integer.
, ?
?


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

2.3. 53

4. .
5. .



.
2.3. integer real
/


1-


2-

+, , *

Integer

Integer

Integer

Integer

Real

Real

Real

Integer

Real

Real

Real

Real

Real

/
Div, mod
Abs, Sqr

Integer

Integer

Integer

Integer

Real

Real

Sqrt, Sin, Cos, Arctan,



Ln, Exp, Pi

Real

Trunc, Round

Integer

. /
6 .
1. +, * .
real,
real. , real
, integer .
, , . ,
,
.
(real).

54 2.
2.
.
3.
. .
4. Abs Sqr .
.
, .
5. Sqrt, Sin, Cos, Arctan, Ln, Exp, Pi
. (
. .
. ,
.)
6. Trunc Round . ,
.
.
,
,
, .
2.10. :
Abs(12 mod 7*4/2-350 div 15)+2


(.2.4).
2.4. 2.8

12 mod 7

.
Abs. -,
-.
mod div . ,
* /. .
.
mod, *, /

2.3. 55

(12 mod 7) * 4

(12 mod 7*4)


/ 2

350 div 15

(12 mod 7*4/2)


(350 div 15) . ,

Abs()

Abs() + 2


-.
div

,
(.2.8). , .
4

. 2.8. 2.10


(.2.5).
2.5.
2.10

12 mod 7

5
Integer

12 7 5.
mod

5 * 4

20
Integer

56 2.
2.5 ()

20 / 2

10.0
Real

350 div 15 23
Integer

.
div

10.0 - 23


. ,
. ,
Real

Abs(-13.0) 13.0
Real

Abs -

13.0 + 2

, 5- .

-13.0
Real

15.0
Real


. 20
2, .0 , ,

.
,
,

: 15.0. Real

2.11. X.
:
X;
X, ;
X .

2.4.

, -

2.4. 57

. ,
, .


2.8. N
program Inp;
uses Crt;
var
N: integer;
begin
ClrScr;
write(' :');
readln(N);

{
.
,
153,
Enter}

writeln(' ', N);


readln

{ .

Enter.

.
,
Alt+F5
}

end.


: (), ,
.
(.2.9).

58 2.

. 2.9. 2.9

2.4. 59
2.9.
program Inp_Color;
uses
Crt;
{ Crt }
var
{ ,
Cl1 Cl2 }
Cl1,Cl2: 0..15;
{ 0..15
.

0 15.
()
integer.

}
X,Y: integer;

{ }

begin
{ 1: }
ClrScr;
{ Window(X1,Y1,X2,Y2)
Crt,
. (X1,Y1)
, (X2,Y2) }
Window(20,5,60,20);
{ 2: }
write(' :');
readln(Cl1);

{


Cl1.

Enter }

{ 3: }
write(' :');

60 2.
readln(Cl2);

{
Cl2.

Enter }

{ 4: }
TextBackGround(Cl1);

{ }

{ 5: }
TextColor(Cl2); { }
{ 6: }
writeln(' X Y');
readln(X,Y);
{
.
()
Enter.
,


.
16 41 }
{ 7: }
ClrScr;

{
,
}

{ 8: }
GoToXY(X,Y);{
X,Y }
{ 9: }
writeln(' !');
readln

end.

{ "" readln
.
Turbo Pascal
Enter }

2.4. 61




,
.
.
Random(X).
, :
Randomize;

{
}

Cl1:=Random(16);{ Cl1

0..15.
Random(N)
0..N-1 }


. Random .
, , ,
. , ,
.
randomize,
. randomize
.
.

Random.

,
10 99. : 90 ( ). ,
Random,
90, Random(90). 0..89, 10..99! , 10. +10.
: Random(90)+10.

62 2.
2.12. ,
.
.
.
2.13. ,
( ). ,
.
!


: TextBackGround(),
ClrScr.

2.5.
?
,
.
.
:
2.10.
Program Piza;
var
G,V,H: real;
begin
G:=9.8; {

}
write(' :');
readln(H); V:=Sqrt(2*G*H);
writeln(' ':20,V:7:3);
{ 20 }
readln
end.

2.5. ? 63


G, , ,
. : , , , .
, G , , (.
). ,
,
.
.
2.11.

Program Piza2;
const
G=9.8;

{ .
var }
{ ,
.
-
real }

var V,H: real;


begin
write(' :');
readln(H); V:=Sqrt(2*G*H);
writeln(' ',V:6:3);
{ "",

}
readln
end.

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

64 2.
-,
. 8.
2.14. .
.

1. , , .
.
, .
2. , ,
const var.
3. integer,
real.
4. .
integer, div mod.
5. real integer trunc round.
6. , .
7.
.


1. , ?
2. , ?
3. ?
?
4. , ,
?
5. mod, div /?

65

6. trunc round? ?
7.
integer? ,
, 10 ?
8. 2,5 16,7?
9. 1E5, 3E-4, .2E7?
10. , ?
11.
trunc(sqrt(2+52 div 8))-sqr(15 mod 4/3)?

,
. , , . ,
.

.

3.1.

,
. Char.
.
.

ASCII
,
ASCII ( ).
, , , . . 8,
1. 28=256 . ASCII
256 : 00000000,
11111111 (255 ).

683.
3.1. ASCII ( )

48

00110000

65

01000001

49

00110001

66

01000010

50

00110010

67

01000011

57

00111001

89

01011001

90

01011010

Char
3.1.
Char
Program Letter1;
var
N: Integer;
X: Char;
begin
X:='L';
{ X
'L' }
writeln(X);
N:=Ord (X); { Ord ,
X,
'L' }
writeln(N);
X:='A';
writeln(X);
X:=Chr (N); { Chr
. X
'L'
N }
writeln(X);
readln
end.

3.1. 69

:
L
76
A
L
3.2.
Program Letter2;
var
X,Y:Char;
begin
writeln(' :');
readln(X);
writeln(X);
writeln(' :');
readln(X,Y);
writeln(X,Y);
readln
end.

,
(, ABC) Enter.
:
A

CAT.
:
CA

Char
. . , ,
.
:
const Leto='X';

703.

3.2. Char !
:
'0'<'1'< '2'< '3'< ...< '9'<... 'A'< 'B'< 'C'< ...< 'X' < 'Y' <
'Z'... ( ).

, Char
.
. Char . Integer
.
3.3. ,
Program Letter3;
var
X1,X2,X3,X4: Char;
begin
X1:='L';
writeln(X1);
X2:=Pred (X1); { Pred


X1 }
writeln('Pred=',X2);
X3:=Succ (X1); { Succ


X1 }
writeln('Succ=',X3);
readln
end.

:
L
Pred=K
Succ=M

3.1. 4-
. 4
3:

71

;
;
.
:
, ,
.
, .
:
FINISHED
OR
PENDING?

DONE.
3.2., ()
.
32 (
). ord('A')=65, ord('A')+32=97, a, chr(ord('A')+32)='a'. , ( !),
, ,
.

- . ,
, .

1. .
2.
ASCII.
3. .
4.
ord chr.
5. Char .

723.
6. .
7. ASCII
.
8. succ pred.


1.
ASCII?
2. ? 15?
3. ?
?
4. F? 87?
5. 3 (a,b,c:char;).
readln (b,a,c ); .
?
6.
c:=succ(pred(succ(D)))?
7. i
i:=pred(ord(F)-2)?

, .
, . ,
. ,
, .
. , . ,
, , ! ,
.

4.1.
!
, .
. , .
, ( ) ( )
:
, ;
, .
, 4>3 , 2>3 .
(
). ,
,
.

4.1. ! 75

(Boolean)

Boolean .
.
4.1.
Program Bool1;
var X: integer;
Bol:Boolean;
begin
X:=4;
Bol:=X > 3;
{ }
writeln(Bol);
Bol:=X < 3;
{ }
writeln(Bol);
readln
end.

:
TRUE
FALSE

TRUE FALSE? :
TRUE , FALSE .


.
(.4.1).
4.1.

Turbo Pascal

<

<=

>

>=

<>

764.

-
, .
,
.
4.2.
program BooleanInput;
var eat:boolean;
ch:char;
begin
write(' [y/n]?:');
readln(ch);
eat:= ch = 'y';
writeln(' :',eat);
readln
end.

4.2. ()
, . , ,
. ,

. .

()

.
.
:
x<7x>3
(and).
, , ,
, .
, . and.

4.2. () 77
4.2.

True

and

True

True

True

and

False

False

False

and

True

False

False

and

False

False

()
:
x > 100 x < 10
(or).
, ,
(false), . (true).
, . or.
4.3.
1

True

Or

True

True

True

Or

False

True

False

Or

True

True

False

Or

False

False

( 2)
:
x > 5, x < 0
-.
,
.
: (true), .
.
xor.

784.
4.4.
1

True

Xor

True

False

True

Xor

False

True

False

Xor

True

True

False

Xor

False

False

?
true 1 ( ), false 0 ( ).


2 (mod 2). 2. ,
.

()
:
(x > 100)
.
. (true ),
(false). ,
(false), (true).
,
. not.
4.5.

not

True

False

False

True


4.3.
Program Bool_1;
var X: Integer;
Bol, OnBol, Rez: Boolean;
Begin
X:=4;
Bol:=X>3;

4.2. () 79
OnBol:=X<3;
writeln('Bol=',Bol);
writeln('OnBol=',OnBol);
Rez:=Bol and OnBol;
writeln('Bol and OnBol=',Rez);
Rez:=Bol or OnBol;
writeln('Bol or OnBol=',Rez);
Rez:=not Bol;
writeln('not Bol=',Rez);
readln
end.

:
Bol=TRUE
OnBol=FALSE
Bol and OnBol=FALSE
Bol or OnBol=TRUE
not Bol=FALSE
4.4.
Program Bol_2;
{ ,
.
, ,
}
var
Price:Boolean;

{
}

Kurs1:Boolean;

{ ,
}

Rezult:Boolean;

{ }

begin
Price:=True;
Kurs1:=True;

{
}
{ - }

Rezult:=Price and Kurs1;


writeln(' - ? -',
Rezult);

804.
Price:=False;

{
}
Rezult:=Price and Kurs1;
writeln(' - ? - ',
Rezult);
readln
end.

:
- ? - TRUE
- ? - FALSE

4.1. 4 , :
Married , ();
Blond , ;
Male , ;
Employed , .
,
, :
1) ;
2) ;
3) ;
4) ;
5) , , .


, , ,
(.4.6). .
4.6.

1 ( )

not

and

3 ( )

or, xor

81

xor or , ,
, .
!

! ,
. ,
. , 2 x 4
(2<=x) and (x<=4).

1. , , .
2. , Boolean.
3. : true
() false ().
4. : >, <, >=, <=, =, <>.
5.
(and, or, xor, not),
.
6. .


1. ?
2.
? ?
3. ?
4.
[3,5]?
5. true or false and false?
6. (x<0) or (x+2)>3?
7. true xor false xor true?

,
, , , , ,
.
, . , .

5.1.

.
.
:
>3, .
-
(.5.1):

()
X>3

()

. 5.1.- , ,

845.
if.

if
if :
if <> then <>

:
if X > 3 then writeln(X);

,
boolean.
.
:
>=3, , '<3'.
1.

: if ... then ... else ....
: if <> then <-> else
<->. (. - .5.2).

. 5.2.- , ,
, X<3

(.5.3).

5.1. 85

. 5.3. If

(S1, S2, S3 .)
!

else !
, if
, if. .5.3. S3 ,
.
(.5.4).
5.1.
program Diskr;
var
A,B,C,D: real;
begin
write(' A,B,C:');
readln(A,B,C);
D:=SQR(B)-4*A*C;
if D >= 0 then
if D > 0 then
writeln(' ')

865.
else
writeln(' ')
else
writeln(' ');
readln
end.

if.

. 5.4.- ,

!

if else
if, else.


, ,
( 23 )
. , ,
var, -

5.1. 87

begin end. .
, .
,
.
. , ,
, var,
var,
begin end, ,
if, if else.
begin end ,
. ,
begin end , , , .

begin end, -

begin/end.


: ,
.
5.1. -
,
:
, ;
, .
5.2. -
,
. 2.

885.

5.2.
if ... then ,
then
. (, if
x<>0 then y:=1/x; x:=0;),
, .
( ), ,
begin end.
:
if X > 3 then begin S1; S2; S3; S4 end;

S1S4 .
(begin S1; S2; S3; S4 end) , . ,
.
5.2.
Program Quad;
var
A,B,C: real;{ }
D: real;
{ }
X1,X2: real;{ }
begin
writeln(' A, B, C:');
readln(A,B,C);
D:=Sqr(B) - 4*A*C;
if D < 0 then
writeln(' ')
else
if D=0 then
writeln(' ',
-B/(2*A):6:2)
else
{ }
begin
X1:=(-B + Sqrt(D))/(2*A);
X2:=(-B - Sqrt(D))/(2*A);
writeln(' :',

5.2. 89
X1:6:2, X2:6:2)
end;
readln
end.

5.3. -
,
Kd Cl. . , Kd=0,
Cl, Kd=1, Cl+16.
,
15.
Turbo Pascal
16.


.
: A, B, C ,
. - .5.5.

. 5.5.- , ,

905.
5.3. ,
Program Mx;
var
A,B,C: integer;
begin
writeln('
readln(A,B,C);
if (A = B) and (A
writeln('
else
writeln('
readln
end.

3 :');
= C) then
')
');

5.4. A, B, C . - .
5.5. ,
, (,
, 6666 3223). -
.
: div mod.
5.6. A, B, C.
, K
.
5.7. X ,
(.5.6), Y. - (.5.7).
5.8. (88)

. (X, Y) (M,N). ,
. , .
5.9. . 7, (red) , (green) .
- (.5.8).
5.10. A, B, C
(, , ).
- .

5.2. 91

. 5.6. - 5.7

. 5.7. - -
, .5.6

925.

. 5.8. - ,
, 7,

5.3.
( case)
if
() .
if, .
5.4.
(0..4)
Program Digit1;
var
Num: integer;
begin
write(' :');
readln(Num);
if Num = 0 then
writeln(');

5.3. ( case) 93
if Num = 1 then
writeln(');
if Num = 2 then
writeln( );
if Num = 3 then
writeln( );
if Num = 4 then
writeln(');
readln
end.

,
case ... of.
:
Case < > of
<1>:<1>;

<N>:<N>
else <>
end
5.5. case ... of

Program Digit2;
var Num: integer;
begin
write( :);
readln(Num);
case Num of
0: writeln(');
1: writeln(');
2: writeln( );
3: writeln( );
4: writeln(')
else writeln( ')
end;
readln
end.

-
(.5.9).
Num case. .

945.
(
real)!

. 5.9.- ,
( 4)

5.3. ( case) 95
5.6.

Program Digit3;
var
Num:integer;
begin
write(' :');
readln(Num);
case Num of
1,2,3 : writeln( );
4,5,6 : writeln( );
7..9 : writeln( ); { 7..9

7 9;
,
7,8,9 }
10..12: writeln( )
else writeln( ')
end;
readln
end.


,
begin ... end.

5.11. ,
Char . , :
0 9;
;
.
case . ,
: 'A'..'Z'.
,
: 'A'..'Z','a'..'z'.

965.

1. , . ( ).
2. , ,
.
3. if.
.
4. if (
then), ( else).
5. if else .
6.
,
begin ... end.
7. then else .
8. ,
,
, case.
9. case end.
,
begin end.
10. , ()
, . .


1. ?
2. ? ?
3. ?

97

4. , ?
5. , ?
6. , ,
?
7. ,
,
?
8. begin
end?

. .
.
,
, ()
, . .
.

6.1. for

for.

. for . for
. :
for < >:=< > to
< > do <>

:
for < >:=< > downto
< > do <>

1006.

for

6.1. 1 10
Program Test1;
var N: integer;
begin
for N:=1 to 10 do
writeln(sqr(N));

{ N
1 10 1 }
{ .
10 }

readln
end.

6.1. N .
(
real). for
. 1!
N=1, N =2
.. N=10.
N
. N 1. -
.6.1.
N = 1,10

. 6.1.- 6.1

N ,
. ,
(
). , -

6.2. 101

, -
- .

, . (
).

for

1. for (for downto do).
6.2. 11 5
Program Test2;
var
N: integer;
begin
for N:=11 downto 5 do
write(N*N*N:5);

writeln;

{ N
-1 }
{ ;
8 ,
N
11 5 -1 }
{ ,

}

readln
end.

6.2.

.
,
- ( ).
,
.

1026.


:
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
- .6.2.

. 6.2.- ,
6.2
6.3.
Program Test3
var
K,M: integer;
begin
for K:=1 to 3 do
for M:=1 to 4 do

6.2. 103
writeln(K,' ',M); {
K M ,

}
readln
end.

K M
1 4. , writeln
12.
6.1. 6 .
6.2. 5
9 4.
6.3. ASCII 0 255
. .


.
6.4. 6 10
Program Test4;
var
N: integer;
S: integer;
begin
S:=0;

{ for }
{
}
{ }

for N:=6 to 10 do
S:=S + N;

{ .

S N.
S
,
}

1046.
writeln(' =', S:6);
readln
end.

- . 6.3.

. 6.3.- 6 10


.
. (.6.1).
6.1. 6.4

for N:= 6 to 10 do

0+6=6

13

6 + 7 = 13

21

13 + 8 = 21

S:= S + N
For N:= 6 to 10 do

6
7

S:= S + N
For N:= 6 to 10 do

S:= S + N
For N:= 6 to 10 do

S:=0

6.2. 105

S:= S + N
For N:= 6 to 10 do

30

21 + 9 = 30

40

30 + 10 = 40

10

S:= S + N
For N:= 6 to 10 do

11
???

writeln(' ', S:3)

= 40

40.
, (if, for ..)
. for .
??? ,
.
,
, .
, ,
.


:
1
1
1
1
1
.
+
+
+
+
1#1 2#2 3#3 4#4 5#5
, 1 5.
, :
1
1 1
= # .
3#3 3 3
:
1
1
1
N#N = N # N .

1066.
- .6.4.

. 6.4.-
6.5.
Program Test5;
var
N: integer;

{ for }

S: real;

{
.
real,

}

A: real;

{ 1/N
( ) }

begin
S:=0;

{ }

for N:=1 to 5 do
begin
A:=1 / N
{ .

,
begin ... end }

6.2. 107
S:=S + A*A;
end;
writeln(' =', S:6:4);
readln
end.

6.4. n! (
n), n .
:
0!=1
1!=1
2!=12
3!=123
........
n!=123....(n1)n
, n! n
.
( P)
( P)
, 1 n. k. : P=Pk
(
: n!=(n1)!n).
: n (n ),
n .
6.5.
S=1+2+3+4+5+6. -
. , 21.
6.2.
6.5

K ()

1086.
6.6.
n (n ):
1
1
1
1
+
+
+
+g
1#2#3 2#3#4 3#4#5 4#5#6
6.7. Crt
, , 16

.
: ,
( 015).
6.8. Crt,
, (*)
.
: 4. X Y. - .
, :

, .
.
6.9. 1000 .

! - .

1.
for.
2. .
3. +1,

for ...:=... to .... do

109

4. 1,

for ...:=... downto .... do

5. , for,
( ) 1.
6. .
7. for for, , ,

.
8.
, , . .


1. ,
?
2. to downto for?
3.
for?
4. :
for i:=2 to 6 do
for j:=5 downto 3 do
writeln('*');

5. , . , .
, ?
6. N
. ,
N .

for, , ,
( , , , ).

. ,
, .
.
: .

7.1.
.
.
.
, (true),
. ,
.


- (.7.1).

1127.

. 7.1.-

:
While < > do <-_>

for if
do .
,
begin end.
!

then, else, do ( if, for,


while) !

, (
begin, end).
then, else,
do, !



, :
1+

x x2 x3
+
+
+
1! 2! 3!

e.

7.1. 113

,
e (),
, ,
e. ,
.
.
xi-1/(i1)!, xi/i! x/i.
- .7.2.

. 7.2.-
(7.1)

1147.
7.1.

Program Summer2;
var
Eps:real;
{ "" }
X: real;

{ }

S: real;

{
}

Y: real;

{ }

i: integer; { }
begin
write(' X Epsilon:');
readln(X, Eps);
Y:=1;

{ }

S:=Y;

{ }

i:=0;

{ }

while abs(Y)>=Eps do {
"",
.
""
1,
! }
begin
inc(i);

{ }
{ }

Y:=Y*X/i; { }
S:=S+Y
end;

{ }
{ .

while
""
}

7.1. 115
{ }
writeln(' =', S:6:4);
readln
end.

7.1. :

1
1
1
1
2 + 2 + 2 + 2 +f
1
3
5
7
, 7.1.
/.


: a, ,
n.
n+1 .
, 2 3 (23):
0 : 20=1
1 : 21=202(12)
2 : 22=212(22)
3 : 23=222 (42)
7.2. a, , n
Program Stp;
var P: real;

{ ,
}

N: integer;

{ }

i: integer;

{ }

A: real;
{ }
begin
write(' :');
readln(A);
write(' :');
readln(N);
i:=0;

{ 0- }

1167.
P:=1;

{ 20=1 }

while i<abs(N) do

begin
inc(i);

P:=P*A

{
,

.
N=0,

,
0- }

{ i 1,
i
}
{ i- ,
A^i }

end;
{ P
N }
if N<0 then { N , }
P:=1/P;

{
}

writeln('=',P:6:3);
readln
end.

7.2.
, N!.
7.3. (
6.8), .
(2-) 3- ( ) 75-
.7.3. -.
!
:
x x 1 !

.

7.1. 117

7.4. 7.3 ,
3.
7.5.
. -
(.7.4).
:x , y,
.


. 7.3.-
2-
3- 75-

. 7.4.


7.6. : 1, 2, 4, 8, 16, 32, 64, 128, 256.


, , 2.

1187.
- (.7.5),
.
7.7. (, A=5 B=8) , .
- (.7.6).


. 7.5. -

2

. 7.6.


7.8. (, A =45 B =8)



( B) ( k) ( A ), .
- (.7.7).

7.2. 119

: k , , B
A.

. 7.7. -

7.2.
.
.
.
, (false),
. ,
.

1207.


- (.7.8).

(true)

(false)

. 7.8.-

,
. , . ,
while , repeat
until .
:
repeat
< >
{ begin ... end ! }
until < >

repeat while
, .
. -
.7.9.
7.3. repeat

Program Summer1;
var
sum, a: real;
begin
sum:=0;

{ sum ,
a }
{ }

7.2. 121
a:=0;

{
(. ) }

repeat
sum:=sum+a; { }
write( :); { }
readln(a)
until a<0;

{
}

{ : }
writeln( =, sum:5:3);
readln
end.

. 7.9.-

repeat until ,
,

1227.
. , .
, .
,
.
-, (.7.10):

. 7.10.-

-
. . 7.3 , S:=S+A
. S:=S+A
A, , . A,
? A ! A , .
: repeat ,
while?
,
, :

7.2. 123
7.4. while

var
sum, a: real;
begin
sum:=0;
write( :);

{ }
{ }

readln(a);

{
A
,

}

while a>=0 do

{
}

begin
sum:=sum+a;

{ }

write( :); { }
readln(a)
end;
{ : }
writeln(' =', sum:5:3);
readln
end.

A A
. while
.


while repeat
,

. , ,
while :

1247.
7.5. while

var
sum, a: real;
begin
sum:=0;
a:=1;

while a>=0 do

{ }
{ ,
7.3
,
while }
{
}

begin
write( :); { }
readln(a);
sum:=sum+a
{ }
end;
writeln( =, sum:5:3);
readln
end.

, .
.
. , , ,
?
!
, ,
.
7.9. , , .
,
10 +10. .

7.2. 125

:
.
7.10. ,
.
7.11. -:
0...100.
10. .

, , ,
.
: 10,
.
:
1.
k,
.
2.
flag,
False. ,
True.
3. , k 10
True ( or).
4. ,
10 .
flag
( ).
- (.7.11).
7.12. (, A =5 B =8)
, . - , .
7.13. (, A=45 B=8)
( k)

1267.
( A),
. - ,
.

. 7.11. - -
(.7.11)

7.14. -
N (.7.12). ,
k
( 4).

7.2. 127
7.1. ,
.7.12 (7.14)

1024

. 7.12.-
N

N.
7.15. -
N
(.7.13). , S (
14).

1287.
7.1. ,
.7.13 (7.15)

4235

. 7.13.-
N

N.
repeatuntil KeyPressed.
KeyPressed
(
Crt
), ,, -

129

. False.
, True. , repeat until
KeyPressed , -
.
, .
, KeyPressed.

1.
:
while < > do <>

2. while ,
false.
3. (while) .
4. :
repeat
< >
until < >

5. repeat ,
true.
6. (repeat) .
7. re
peatuntil (beginend) ,
repeatuntil .


1.
for, ?
2. while
repeat until?

1307.
3. ? (
.)
var
k,x,i: integer;
begin
{ 1 }
k:=256;
while k<>1 do
begin
write(k:4);
k:=k div 2
end;
{ 2 }
k:=5;
repeat
writeln(k);
k:=k+5
until k>30;
{ 3 }
for i:=1 to 5 do
writeln(i*5);
{ 4 }
for i:=8 downto 4 do
write(i:3);
{ 5 }
for x:=1 to 79 do
begin
gotoxy(x,8);
write('*');
gotoxy(x,15);
write('*')
end;
end.

, .
.

.
(
).
. ?
:

. ,
, . ,

.

8.1.

,
.
. ,
.
.
.

( ) .
(.8.1).

8.1. 133

10

8 14 25 12 10

. 8.1.
A , .
A[3]=8. :

A ;
3 ();
A [3] 3- ;
8 3- .


:
;
;
;
;
;
;
.


< >: array [< >] of < >;

< > , , < > .


:
var A: array [1..10] of integer;

,
1 10, ( ) .

1348.



, .
- .8.2.

. 8.2.-

8.1.
Program Massiv1;
uses Crt;
const
{ ,
,


}
N=10;

{
( var) }

var
A: array [1..N] of integer; { 1..N .

,

8.1. 135
1 N,
N
const }
i:integer;

{ ,
, }

begin
{ II.
}
Randomize; { }
{ : }
for i:=1 to N do

A[i]:=Random(100);

{ i
1 N,

}
{
A[i]
0 99.
: i
(
""), A[i] }

{ III. }
ClrScr;
writeln(' :');
for i:=1 to N do
write(A[i]:4);
{
4
,
! }
writeln;

readln
end.

{ ""



}

1368.

0 99. random(100).
, ? : random(N)
N 0 N 1. ,
K, ,
K random(N). , random(N) + K,
.
, , 100..+100. , : 100, 100 .
201. : 1. , N =201, K=100.
random(201)-100.

,
.
, Turbo Pascal. ,
Turbo Pascal random.
word. , . 100
, 100, , Turbo
Pascal . (random) ,
-100 + random(201). Turbo Pascal
integer (100), .
8.1. , .
begin end.
8.2. 8.1
( ).
.
!

.
, ,

8.1. 137

, - . ,
, .
(for, while
repeat) , .


(type). -

( 8.1). ,
,
.
8.2.
Program Massiv2;
const
N=10;
type

{ .
,

n }

Mas=array [1..N] of integer;


{ 1..N ;
,
1 N,
N const }
var
Line:Mas;

{ Line ,
Mas }

i:integer; { ,
, }
begin
{ IV. }
for i:=1 to N do

{
, }

1388.
begin
{ }
write(' ',i,':');
readln(Line[i]) { i-

(Line[1],Line[2] ..) }
end;

{ }

{ :}
for i:=1 to N do

{ N
}

write(-Line[i]:5);

writeln;

{ 10
.

}

{
}

readln
end.

, ,
.
.
,
:
For i:=1 to N do
Line[i]:=-Line[i];

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

8.1. 139

, , . !
8.3. :
1) A 10 (
);
2) ;
3) (-
.8.3);
4) .

. 8.3. -

8.4. :
1) A 10 ;
2) ;
3) (-
.8.4) :
1- 2-;
3- 4-;
5- 6-;
7- 8-;
9- 10-
( ,
(.2.4));

1408.
4) .

. 8.4.-


- . , . ,

.
8.3.
(. - .8.5)
Program Maximum;
const
N=10;
type
Mas=array [1..N] of integer;
var
:Mas;
i

:integer;

Max :integer;

{ }
{
}

8.1. 141
Imax:integer;

{
}

begin
{ }
{

}
Randomize;
for i := 1 to N do
begin
[i]:=-50+Random(101);
write(A[i]:5)
end;
writeln;
{ V.
}
Imax:=1;

{ ,

}

Max:=[1]; {

Imax Max }
for i := 2 to N do

{


( ) }

if Max < [i] then {



... }
begin
Max:=[i];

Imax:=i

{ ...

}
{

Max Imax }

1428.
end;
writeln(' =',Max:5);
writeln(' =',Imax:5);
readln
end.

, .
, .

. 8.5.-

, Max. , ,
Imax. , ,
Imax,
(A[Imax]).

8.1. 143

, :
8.4. , ,
Program Maximum2;
const
N=10;
type
Mas=array [1..N] of integer;
var

:Mas;
i, imax
:integer;
begin
Randomize;
for i := 1 to N do
begin
[i]:=-50+Random(101);
write(A[i]:5)
end;
writeln;
{ V. }
imax:=1;
for i := 2 to N do
if A[imax] < [i] then
imax:=i;
writeln(' =',A[imax]:5);
writeln(' =',imax:5);
readln
end.

8.5.
(-
.8.6).
8.6. 10

. , , . ( , 0 , [i]:=0.)
.

1448.

. 8.6.-

8.7. 10 . , ,
.



, - . ,
: ( for ) -

8.1. 145

( if).
, (S:=S+A[i]).
8.5.
program PositivSumm;
const
N=10;
type
Mas=array [1..N] of integer;
var a:Mas;
i:integer;
{ }
S:integer;

{

}

begin
{
-100..+100 }
randomize;
for i:=1 to N do
begin
a[i]:=-100+random(201);
write(a[i]:5)
end;
writeln;
{ }
S:=0;

{ S .

.

,

.
}

for i:=1 to N do { }
if A[i]>0 then
S:=S+A[i];

{
}
{ ,

}

1468.
{ : }
writeln(' =',S);
readln
end.

, :
.
: ,
, ,
(k:=k+1).
8.6. ( .8.7)
program EvenCount;
const
N=10;
type
Mas=array [1..N] of integer;
var a:Mas;
i:integer;
{ }
K:integer;

{
}

begin
{
+10..+100 }
randomize;
for i:=1 to N do
begin
a[i]:=+10+random(91);
write(a[i]:5)
end;
writeln;
{ }
K:=0;

{ K .
,
:
,
,
,
K .

8.1. 147

,

.
}
for i:=1 to N do

{ }

if a[i] mod 2 = 0 then {


,
,

2 }
K:=K+1; { ,
}
{ : }
writeln(' =',K);
readln
end.

. 8.7.-

1488.

8.2.
,
, .
, .



: ,
.
:
.
. ? ,
? ?
.
.
8.7.

program Search1;
const N=10;
type
mas=array [1..N] of integer;
var a:mas;
i:integer;
fl:boolean;
{
}
begin
{ }
randomize;
for i:=1 to N do
begin
a[i]:=-2+random(20);
write(a[i]:4)
end;
writeln;
{ }
{
}

8.2. 149
fl:=false;

{ = false,
}

for i:=1 to N do
if a[i]<0 then {
}
fl:=true;

{ ,

"" }
if fl then
{ }
writeln(' ')
else
writeln(' ');
{ }
readln
end.



, .
, . ,
.
8.8.

program Search2;
const N=10;
type
mas=array [1..N] of integer;
var a:mas;
i:integer;
fl:integer; { ,
}
begin
{ }
randomize;
for i:=1 to N do
begin

1508.
a[i]:=-2+random(20);
write(a[i]:4)
end;
writeln;
{ }
{
}
fl:=0; { = 0,
}
for i:=1 to N do
if a[i]<0 then {
}
fl:=fl+1; {
}
writeln(' =',fl);
if fl>0 then
writeln(' ')
else
writeln(' ');
{ }
readln
end.


- ( ).
.
8.9.

program Search3;
const N=10;
type
mas=array [1..N] of integer;

8.2. 151
var a:mas;
i:integer;
fl:integer;

{
}

begin
{ }
randomize;
for i:=1 to N do
begin
a[i]:=-2+random(20);
write(a[i]:4)
end;
writeln;
{ }
{
}
fl:=0; { () = 0,
}
for i:=1 to N do
if a[i]<0 then
fl:=i;

{
}
{ ,
}

{ fl ,
.
fl ,
}
if fl>0 then
writeln(' =',fl)
else
writeln(' ');
{ }
readln
end.

1528.
, :
,
?

, : .
.
?
( ) , :
for k:=N downto 1 do

.
,
? ,
.
for, , while,
:
k:=1;
while a[k]>= 0 do {
( ) }
inc(k); { }

.
inc, .
.
inc(k) k:=k+1. inc,
Turbo Pascal dec.
.
, .
k:=k+1 k:=k-1, , inc(k) dec(k).

: ,
.
,
. ,
.
.
.

8.2. 153
8.10.
( )
program Search4;
const N=10;
type
mas=array [1..N] of integer;
var a:mas;
i:integer; {
}
begin
{ }
randomize;
for i:=1 to N do
begin
a[i]:=-2+random(20);
write(a[i]:4)
end;
writeln;
{ }
{
}
i:=1;

{ while
for,
}

while (a[i]>=0) and (i<N) do {



() .
,
}
inc(i);

{ }

{ . ,
}
if a[i]<0 then
{ , ,
- , .
- }
writeln(' =',i)

1548.

else
writeln(' ');
{ }
readln
end.

8.8.,
, , , .

8.3.
. , .
.
. ,
.
,
.
()
() () (.8.8).
j
3

...

Table[n,m]

..

...
n

Table[2,3]

. 8.8.

8.3. 155

54, ,
.
: ,
. - .8.9.
8.11. 54,
program Massiv_2;
const
N = 5;
{ }
M = 4;
{ }
var
Table : array [1..N, 1..M] of integer; {

N M }
{ , ,
,
.
,
, .
, ,
}
i, j : integer;

{
}

begin
{ :}
randomize;
for i:=1 to N do
for j:=1 to M do
Table[i,j]:=Random(100); {


i
j }
{ : }
for i:=1 to N do
begin
for j:=1 to M do

1568.
write(Table[i,j]);
writeln

{

i }

end;
readln
end.

. 8.9.- 54
;

8.9. , :
35;
;

.

1. ( ).

157

2. ,
(array), ( ) , :
mas: array [1..20] of integer;

3.
() .
4. ,
.
5.

.
6.
(). ,
.


1. , ?
2. A[4]=12 , , ?
3. ?
4. , ?
5. -
?

.
.

.

, .
.
.

9.1.


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

(.9.1).

1
1-

1
2-

2
2-

2
1-

3
2-

3
1-

4
2-

. 9.1. ,

1609. .
, ,
() .
.
:
,
;
, .
,
, ;
;
.



: , 8.3, 8.4 (. 8.1):
) 10 20 +20;
) ;
) ;
) :
1- 2-,
3- 4-;
5- 6-;
7- 8-;
9- 10-;
) .
(.9.2).
: ) )
.
, .

9.1. 161

. 9.2.- 9.1

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

( ) .
,
(procedure function ). begin,
. -

1629. .
(var)
begin end,
( ).
!
9.1.

Program Massiv_1;
const
N=10;
type
Mas=array [1..N] of integer;
var { .
,
, , .
,
,
, ,
}
Line: Mas;
Sm

{ Line .
Mas }

:integer; {
}

{ .
!

! Inp
! }
Procedure Inp;
var

{ Inp }

{ ,
Inp,
}
i:integer;

{ ,
,
.

9.1. 163
i

i.
,
.
(Inp)
i
.
, , ,
i
.
.

,
}
begin
{ Inp }
for i:=1 to N do
begin
write(' ',i,':');
readln(Line[i])
end
end;
{ Inp }
{ }
Procedure Out;
var
i:integer;

{ Out }

{
,

,
.
,
}
begin
{ Out }
for i:=1 to N do
write(Line[i]:5);
writeln
end;
{ Out }
{ }
Procedure Change;

1649. .
var
i:integer;
X:integer;

begin

{

}
{ Change }

i:=1;
{ }
{
2. for ... ,
while ... do }
while i<10 do {
i- i+1- }
begin
X:=Line[i];
{
}
Line[i]:=Line[i+1]; {
}
{

}

i:=i+2

{ 2

}

end
end;

Line[i+1]:=X;

{ Change }

{ }
Function Sum:integer;

{ .

.

.


.

}

9.1. 165
var
i:integer;
S:integer;

{ }

begin
{ Sum }
S := 0;
for i := 1 to N do
S := S + Line[i];
Sum := S;

end;

{ !


Sum }
{ Sum }

{ }
begin

{
begin }

Inp;

{ }

Out;

{ }

Sm := Sum;{ }
writeln(' =',Sm);

{
}

{
( Sm:=Sum)
: }
writeln(' :',Sum);
Change;

{ }

Out;

{ }

readln
end. { . }

1669. .
9.1. , :
) 14 (
);
) ;
)
(.9.3); (. .9.4);
A

. 9.3.

. 9.4.-

) ;
) .
.

9.2. 167

9.2. :

9.2.
Program Maximum;
const
N=10;
type
Mas=array [1..N] of integer;
var
{ }
Line: Mas;

{ Line .
, Mas }
m,i : integer;
{
}
function Maxim:integer;
var

{ }
imax:integer;

{
}

{ i
i }

:integer;

begin

{ }

imax:=1;

{
}

for i := 2 to N do

{


(, 2-
) }

if Line[imax] < Line[i] then

{

i-
... }

1689. .

imax:=i;

{ ... i-
}

Maxim:=imax { ,

}
end;

{ }

begin

{ }

{
}
Randomize;
for i := 1 to N do
Line[i]:=Random(100);
m:=Maxim;

{
}

writeln(' =',Line[m]:5);
writeln(' =',m:5);
readln
end.

9.2. ,
20, 20 +20,
20 : , , .
.
, 20,

, .

1. .
() .

169

2. .

(, ).
3. .
4. .
5. (, ).
6. , .


1.
2.
3.
4.

?
?
?

, ?

10

, , , , .
`
, , .
.

10.1.
: String
( )
Turbo Pascal String. -
. , , . ,
.


String
var:
S: String;

S 255

, , , 255. (
256,
.)
,
.
, S1 : String[40]; , S1
0 40 .

17210.


,
(/, , ).
10.1.
Program Line_1;
var
Name1: String[20]; { 20 }
Name2: String[20];
Title: String[40]; { 40 }
Rez:
String[70];
begin
Name1:='._'; {
< =
,
var
}
Title:=' Turbo Pascal';
Rez:=Name1+Title;

{ .
,


.

,
,
}

writeln(Rez);
{ :
._ Turbo Pascal }
{
(): }
writeln(' :');
readln(Name1);
writeln(' :');
readln(Name2);
if Name1 = Name2 then
writeln(' ');
if Name1 < Name2 then

10.2. 173
writeln(' ');
readln
end.

255 (255 ).
(
1 ).
10.1. , .

10.2.



.
- ,
.



,
-.
, ,
- .
10.2.
Program Line_2;
var
Str:String;

{
255 }

Word1,Word2:String[20];

Len:byte;

{
-
- }

17410.
-.
byte
0..255 }
Position:byte; { ,

-
( ) }
begin
writeln(' -:');
readln(Word1);
writeln(' -:');
readln(Word2);
writeln(' :');
readln(Str);
Len:=Length(Word1); { Length
Word1 }
Position:=Pos(Word1,Str); { Pos(Word1,Str)
Str,
- Word1.
, Pos 0 }
while Position<>0 do { Str
- }
begin
Delete(Str,Position,Len); { Delete
Len Str,
Position, - }
}
Insert(Word2,Str,Position); { Insert
Word2 Str,
Position. ,
}
Position:=Pos(Word1,Str)

{
-

while }

end;
Str:=Copy(Str,2,length(Str)-2); { Copy

, ,
,

10.2. 175
. ,
Copy Str,
}
writeln(Str);
readln
end.

10.2. ,
.
, .



. , String
array [1..255] of char. ,
, () ,
( ). ,
, ( , ,
).

. ,
/ ,
Insert Delete.
,
.
10.3.
Program String_3;
var
Str:String;
{ }
i,k:integer;

{
}

begin
writeln(' :');
readln(Str);
k := 0; { }

17610.
for i:=1 to Length(Str) do {
Str }
{ - }
if (Str[i]='(') or (Str[i]=')') then
k:=k+1; { }
writeln(k);
readln
end.

1.
String.
2. , .
3. ,
, 255.
4. String

.
5. , , .


1.
50, ?
2. 200, String, (+)
100,
?
3. ?
4.
?
5. , (,
)?

11

, 9,
. - . ,

, ,
. .

11.1.

, ,
w r i t e l n ( ! ) .
, , .

.


11.1.

program Param1;
uses Crt; {
}
{ Stars
}

11.1. 179
procedure Stars(N:integer); {

.

N
( integer),

,
}
var i:integer; { }
begin
for i:=1 to N do { N
,

"*" }
write('*')
end;
{ Cross
(X,Y) }
procedure Cross(X,Y:integer); {
,

}
begin
gotoxy(x,y-1);
writeln('|');
gotoxy(x-2,y); writeln('--+--');
gotoxy(x,y+1);
writeln('|')
end;
{ }
begin
clrscr;
{ ,
}
Stars(10);
gotoxy(6,20);

{ 10
}

18011.
Stars(70);

{
20- }

Cross(40,13); { }
Cross(70,5);

{
}

readln
end.

:
, , .
. .
N:=N+2, N 2. ,
,
.



, ,

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

11.1. 181


, , .
11.2.

program Param2;
{ }
function tg(x:real):real; {
,
.

, ,
, }
begin
tg:=sin(x)/cos(x) {
.

}
end;
{ x,
n }
function Stepen(x:real; n:integer):real;
{ ,

}
var
i:integer;
y:real; { }
begin
y:=1;
{
-
}
for i:=1 to n do
y:=y*x;
Stepen:=y
end;

18211.
{ }
begin
writeln(' /6=',tg(Pi/6):7:3);
{ ,
}
writeln(' 2.5 8 ',
Stepen(2.5,8):7:3);
{ ,
}
writeln(' /3 5 ',
Stepen(tg(Pi/3),5):7:3);
readln
end.

11.2.
, inc().
?
11.3.,
program Param3;
var a,b:integer;
{ }
procedure Change(var x,y:integer);
{ ,

,
var.
.
,
,
}
var z:integer; { }
begin
z:=x;
x:=y;
y:=z
end;

11.2. 183
{ }
begin
a:=5;
b:=8;
writeln(' A=',a,' B=',b);
Change(a,b);

{ ,

,
.

}

writeln(' A=',a,' B=',b);


readln
end.


, (
var)
.
,
.
,
.
, ,
, .
! ,
, , -. ,
!
, , . ,


, .

,
.

18411.

, ,
, , ,
.
, ,
. !
11.1. ,
1234 4321.
11.2. ,
. , 5 8
1,5 1,5, 3,2 0,8 1,2 1,2.

1.
.
2. .
3. .
4. .
5. ,
, var.
6. ,
!


1. , .
2.
?

185

3.
? ?
?
4. :
procedure Maxim(var x,y:integer);
begin
if x>y then y:=x
else x:=y
end;

:
x:=2; y:=3;
Maxim(y,x);

x y?
5. :
procedure Mult(var x:integer;y:integer);
begin
x:=y*2
end;

:
x:=2;
Mult(x,2*x);

x?

12
:

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

.

12.1.

, . , ,
, . ,
, .
.

(ASCII). ,
. ,
, .


, .
,

18812. :
. ,
, ( ). ( )

().
.
.
,
Turbo Pascal work.
txt. ,
(.pas) .
. ,
.
12.1. work.txt
Program File_1;
var
Fil: text; {
}
{ .

.
text.
,

(, ) }
Str : string; {
}
begin
{
: }
Assign(Fil,'work.txt'); { Fil


(
work.txt) }

12.1. 189
Reset(Fil);

{
" ".

{ work.txt
. work.txt
, ,
" ".
Eof (end of
file).
, , ,
Eof, False
("").
( ), Eof
True ("") }
while not Eof(Fil) do

begin
readln(Fil,Str);
writeln(Str)
end;
Close(Fil)

{
, Eof
False.

,

not }
{
work.txt }

{
}
{

}

end.


, , ,
reset.
, -

19012. :
readln read
.
,
, .
rewrite . ,
assign, .
, .
,
, (writeln) (write).

work.txt user.txt.
12.2.
Program File_2;
var
Fil_1, Fil_2: text; {
}
Str : string;

{
}

{ }
Procedure New_file;
var
I : integer;
begin
Assign(Fil_1,'work.txt');
Rewrite(Fil_1);
{
"
".

(
).
}
{
work.txt }
for I:=1 to 3 do
begin
writeln(' Enter:');
readln(Str);

{
Str }

12.1. 191
writeln(Fil_1,Str) { Str
.

,
,
}
end;
Close(Fil_1)
{ .



}
end;
{ work.txt
user.txt }
Procedure Copy_file;
begin
Assign(Fil_1,'work.txt');
Reset(Fil_1);

{
" ".

Assign(Fil_2,'user.txt'); { Fil_2
,

}
Rewrite(Fil_2);

{
" ". }

while not Eof(Fil_1) do

begin
readln(Fil_1,Str);

{
, Eof
False.

,

not }
{
work.txt }

19212. :
writeln(Fil_2,Str)
end;
Close(Fil_1);
Close(Fil_2)
end;
begin

{
user.txt }

{

}
{ }

New_File;

{ }

Copy_file

{ }

end.

( Open Turbo
Pascal
) , .

-, ,
, . ,
Turbo Pascal MS-DOS, ,
, MS-DOS.
, MS-DOS
(, Norton Commander),
( , MS Word).
12.1. , :
) ;
)
;
)
.
!

12.2. 193

12.2.

.
,
, :
.



12.3.
Program File_3;
var
A,B:integer;
Fil:text;
begin
A:=3;
B:=10;
Assign(Fil,'prim.txt');
Rewrite(Fil);
write(Fil,A,' ');

{
prim.txt

3,
}

write(Fil,B);

{

}

Close(Fil)
end.

12.2. prim.txt .

19412. :


,
. :
, ,
.
12.4. 54

program File_4;
const
M=5; N=4;
var
Fil:text;
A:real;
S:char;
I,J: integer;
begin
assign(Fil,matrix.txt);
rewrite(Fil);
randomize;
{ }
for I:=1 to M do
begin
for J:=1 to N do
begin
A:=random(100);
{

}
write(Fil,A:5:3, ) { A

,
}
end;
writeln(Fil)

{ i-
.

12.2. 195


}
end;
close(Fil);
{ .
assign(Fil)
}
reset(Fil);
while not eof(Fil) do
begin
while not eoln(Fil) do

begin
read(Fil,A);

{ eoln(Fil)
.

boolean.

,
.
eoln

(
) }
{
}

write(A:5:3);

{ }

read(Fil,S);

{
.
.


A }

write(S)
end;
writeln;

{ }
{

}

19612. :
readln(Fil)

{

}

end;
close(Fil);
readln
end.
12.5.
program ReadMatrix;
const
M=5; N=4;
var
Fil:text;
A:array[1..M,1..N] of real;
S:char;
I,J: integer;
begin
assign(Fil,matrix.txt);
reset(Fil);

{ ,
}

{ }
for I:=1 to M do
begin
for J:=1 to N do
begin
read(Fil,A[I,J],S);

{
.
S

}

write(A[I,J]:6:3, ) {

}
end;
writeln;

{
}

12.2. 197
readln(Fil)

{
}

end;
closefile(Fil);
readln
end.

12.3. prim.txt
.
12.4. matrix.txt,

rezult.txt.


rewrite, ,
, . -
, append.
, , .
12.6.
program File_6;
const
M=5; N=4;
var
Fil:text;
append(Fil);

{

}

writeln(Fil, ); {
}
close(Fil);
readln
end.

, , ,
(write writeln) , .

19812. :
read readln. , .
con (). ,
, Turbo Pascal con,
. , Turbo Pascal con,
.
: con (assign(Fil,con))
(rewrite(Fil))
- (, writeln(Hello, world!)).
Turbo Pascal .
, - lpt1.

1. .
2. .
3. text ASCII.
4. ,
.
5. ,
.
6. assign
(reset) (rewrite).
7.
write/writeln read/readln
.
8.
close.

199


1. , ? ,
?
2. ?
3. ,
?
4. example.txt,
5 ( 9).
:
assign(f,example.txt);
rewrite(f); writeln(f,');
close(f);

, ?
5. , rewrite
append.
6. 10 ( 0 9),
. :
for i:=1 to 9 do
begin
read(f,c); x:=ord(c)
end

x (i,x:integer;
c:char;)?

13
.
Graph

, , ,
.
.
8025 (. 1.2).
Turbo
Pascal .

13.1.

,
Crt

, .


, .
, x y (.13.1), ( ).
0
0

479

639

(0,0)

(639,0)

(0,479)
y

. 13.1.

20213. . Graph
Graph, , Turbo Pascal
640480 .

.
Turbo Pascal egavga.bgi.
.

BGI Turbo Pascal.
(0,0).
. (640480)
. ( egavga.bgi,
svga.bgi, ). Turbo
Pascal, .

Turbo
Pascal .
, .
,
( ).
Graph.
.
13.1.
uses
Graph, Crt;

{ .
Crt }

13.1. 203
var
Gd,Gm:Integer; { Gd
}
{ Gm ;

( ) }
Color : byte;
begin
Gd := Detect;

{
}

InitGraph(Gd,Gm, ); { .

-
bgi.
,


(
Turbo Pascal).

, ,

egavga.bgi,


InitGraph. ,
InitGraph(Gd,Gm,c:\sys\tp71\bgi) }
If GraphResult <> grOK then {

}
Halt(1);
Randomize;
{
100x100,
}
repeat
Color := Random(15);

20413. . Graph
PutPixel(Random(100),Random(100),Color);
{ PutPixel(X,Y,C)
(,Y) .
}
Delay(10)
until KeyPressed;
CloseGraph

{


}

end.

13.1. , :
(640480);
;
( ).

13.2.
Graph
,
.
Graph .
,
.

Graph
.
SetColor. Line.
13.2.
uses
Graph, Crt;
var

13.2. Graph 205


Gd,Gm:Integer;
Color : byte;
begin
Gd := Detect;
InitGraph(Gd,Gm,);
If GraphResult <> grOK then
Halt(1);
Randomize;
{ ()
200200,
}
{ Line(X1,Y1,X2,Y2) .
(1,Y1),
(X2,Y2).
.
SetColor() .
! }
repeat
SetColor(Random(15));
Line(Random(200),Random(200),
Random(200),Random(200));
Delay(10)
until KeyPressed;
Readln;
CloseGraph
{
.
readln
CloseGraph,
(

) }
end.

13.2. , (640480),
, (.13.2).

20613. . Graph

. 13.2. 13.2

13.3. ,
:
(.13.3).

. 13.3. 13.3


Graph
,
. Circle.
13.3.
uses
Graph, Crt;
var
Gd,Gm,r:Integer;
Color : byte;
begin
Gd := Detect;
InitGraph(Gd,Gm,);
If GraphResult <> grOK then

207
Halt(1);
Randomize;
{ 10 }
for r:=1 to 10 do
begin
SetColor(random(16));
Circle(320,240,r*5) { Circle(X,Y,R)

(X,Y)
R }
end;
Readln;
CloseGraph
end.

Graph (,
ellipse, bar, rectangle, outtext),

Turbo Pascal Graph,


Ctrl+F1,
Graph. ,
.

1. .
egavga.bgi.
2.
(640480). ( , )
.
3. Graph.

20813. . Graph
4. InitGraph.
CloseGraph.
5. Graph
.
Graph
Graph Ctrl+F1.


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

?

14
,

.

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

, . , , , ifelse.

,
goto .
, ,
,
, .
goto. , ,
, , . ,
goto,
.

14.1. 211


, goto
, .
, ,
. -
.

14.1.
goto
goto
.
goto.
(, ).
.
, ? ,
.
? : .
, , .
, .
(
), ( ),
. , .
N2 (, (N2N)/2).
, -
, . , .
goto.
14.1.
program use_goto;
label konec;

{ ,
goto,

21214. ,
.
Label
,
}
const N=10;

{ }

var a:array[1..N] of integer;


i,j:integer; { }
fl:boolean;
begin
{ }
randomize;
for i:=1 to N do
begin
a[i]:=random(15);
write(a[i]:4)
end;
writeln;
fl:=false;

{ fl ()
,
,
}

for i:=1 to N-1 do


for j:=i+1 to N do
if a[i] = a[j] then
begin
fl:=true;
goto konec

{ "konec" }

end;
konec:

{
}

if fl then
writeln(' ')
else

14.1. 213
writeln(' ');
readln
end.

, goto ,

.

goto.
14.2. goto
program without_goto;
const N=10;

{ }

var a:array[1..N] of integer;


i,j:integer;

{ }

fl:boolean;
begin
{ }
randomize;
for i:=1 to N do
begin
a[i]:=random(15);
write(a[i]:4)
end;
writeln;
fl:=false;

{ fl ()
,
,
}

{ for while,

}
i:=1;
while (j<N) and not fl do {
:


}

21414. ,
begin
j:=i+1;
while (j<=N) and not fl do
begin
if a[i] = a[j] then
fl:=true;
j:=j+1
end;
i:=i+1
end;
if fl then
writeln(' ')
else
writeln(' ');
readln
end.

- while
for, goto.

14.2.,

, . (,
for, while repeat).

break
break
, .
, break
.
break.
14.3. , 17
var i:integer;
begin
for i:=10 to 99 do
if (sqr(i mod 10) + sqr(i div 10)) mod 17 = 0

14.2., 215
then break;
writeln(i);
readln
end.

break -, , .
(14.3),
,
while, .
14.4. ,
17 ( break)
var i:integer;
begin
i:=10;
while (sqr(i mod 10) + sqr(i div 10)) mod 17 <> 0 do
i:=i+1;
writeln(i);
readln
end.

continue
continue . continue
. ,
.
continue, break, .
continue.
14.5. ,
17
var i:integer;
begin
for i:=10 to 99 do
begin
if (sqr(i mod 10) + sqr(i div 10)) mod 17 = 0
then continue;
writeln(i)

21614. ,
end;
readln
end.

break, continue
.

1. . .
2.
goto.
.
3. , goto,
,
.
4. label.
5. goto.
6.
break continue.
7. break . ,
.
8. continue . .


1.
goto?
2. goto?
3. break continue?
4.
break? ?

15
:

. .
,
. , ,
, .
, . (
) ,
.
, , , . ,
-
.
, . ,
, , , , .
(, , ,
, boolean). ,
, .
.
, , !

! ()
.

.

15.1. record 219

15.1. record
. , .
. , ,
(record).
:
record <
> end;
15.1.
var
Vasya,Petya: record
Name,Family,Class:string[20];
Height:integer;
Weight:real;
Men:boolean
end;

, record end .
.


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

22015. :
15.2.
var
Vasya,Petya: { }
record
Name,
{ }
Family,
{ }
Class:string[20]; { }
Height:integer;
{ }
Weight:real;
{ }
Men:boolean
{ (? /) }
end;
begin
Vasya.Name:=''; {

,
}
{
}
readln(Vasya.Family);
Vasya.Height:=170;
Vasya.Height:=Vasya.Height+5;
Vasya.Weight:=65.3;
Vasya.Men:=true;
Vasya.Class:='10';
Petya:=Vasya; {
.

}
Petya.Name:=''
end.

,
var , type

.
( record end),
, .

15.2. 221

(
case), end
begin.

15.2.

.
, . ,
, .
: (record x,y:real
end ); , ( record name,firstname:
string[30]; man:boolean end).



( type)
.
15.3.
type coord=record
x,y:real
end;
people=record
name,
family:string[30];
man:boolean
end;
var
pointA,pointB : coord;
Vasya : people;

22215. :
, ,
, .
15.4.
type coord=record
x,y:real
end;
var
points : array [1..20] of coord;
{ of
record .
}
i : integer;
begin
for i := 1 to 20 do
begin
points[i].x := i*5;
points[i].y := 0
end
end.

with
, ,
. ,
( )
, , ,
.
:
with < > do <, >
15.5. with
type coord=record
x,y:real
end;
var
points : array [1..20] of coord;
i : integer;

15.2. 223
begin
for i := 1 to 20 do
with points[i] do
begin
x := i*5;
y := 0
end
end.

, with, ,
with.
15.5 points[i] x y i.
, ,
, . with .
15.6. ,
with
type coord=record
x,y:real
end;
var
points : array [1..20] of coord;
i,x
: integer;
begin
x := 10;
for i := 1 to 20 do
with points[i] do
begin
x := x*5; {

points[i].x. x
}
y := 0
end
end.

, , .

22415. :


, .
, .
,
, .
: , , ,
, , .
. ,
(string).
, .
(integer). .
100, ,
. . .
real.
:
15.7.

const n=100;
type
book=record
title
: string[40];
author
: string[25];
publishing : string[25];
year
: integer;
pages
: integer;
price
: real;
end;
var
books : array [1..n] of book;

{
{
{
{
{
{
{

}
}
}
}
}
}
}

, , .
15.7. ,
. ,
, -

15.2. 225

. , , .
, ,
- iii,
( ; , count_people)
, :
var count_people : integer; {
, }


, , ,
, ,
.
.
15.8.

{ ,
"" }
const n=100;
{
type
point=record
{
x,y : integer
{
end;
cells=array[1..n] of point; {
snake=record
{
body
: cells;
{
length : integer;
{
start : integer;
{
finish : integer
{
end;
var
pitons:array [1..5] of snake; { 5
begin
{ "y"
3- }
pitons[3].body[pitons[3].start].y:=10;
end.

}
}
}
}
}
}
}
}
}
}

22615. :

1. .
2. ,
.
3. record end ,

.
4. . .
5.
with.


1. ?
2. ?
3. ,
(, , ,
100 /, ).
4. , .3.
5. 5-
.4.
6.
?

16

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

16.1.

, ,
.
, .
, .
(
hardware
). .
(software).
. ,

, ().

16.1. 229

(,
- , ).
, , .
, , , .
,
, .
(,
ROM
) (, RAM

). (
,
).
(,
),
( ), (), ,
.
, , , , , .
, ,
( )
(). ,
(
).
,
(), (
). ,
.
,
.
(
MS
-
DOS
, ),
, (
).
.

23016.
Turbo

Pascal
MS-DOS.
, ,
64 (65536) (
16- ).
, ,
( ) , ,
40000 (40000 2
, 65536).
,
, (, Borland Delphi).
(), .

16.2.
, ,
, .
( , 16-, 32-
64-). (),
.
: var a,b:integer ,
, 2 , Integer ( Turbo Pascal
2, Delphi 4). (,
)

a b.

, .
, .
, a , ,
+4 , , b +6. ,
,
.

16.3. 231

.
a b .

. , , , , .
, , ,
.
.
- , .

16.3.

. , var. :
< >: ^< ,
>;

, ,
^ (, Shift+6
).
(), ,
- . ,
. :
var p:^integer;

, p
.

,
, . .

, . ,
, (

23216.
- ,
, ).
,
, , , ,
. , .
,
- .

. , ?
, -
,
. - ,
!
.
, .
, . , ,
.
-.
- ( ),
@ (, AT, Shift+2).
: p:=@count; ( p
, count, p
, count).
,
-, ^
(), -. :
p^:=10; ( , p, 10).
16.1. -
var
vasya,petya : integer; { }
p,q
:^integer; { integer
}
begin
vasya := 10;

16.4. 233
p := @vasya; { p
vasya }
q:=p;
{ }
q^:=15;
{ vasya 15,
q ,
p, p vasya }
p^:=q^+5;
{ vasya 5 }
end.


- inc dec.
. 1 (
), , ,
. ,
.
16.2.
var
a : array [1..20] of integer;
p :^integer;
i : integer;
begin
p:=@a[1]; { - p
}
{ }
for i:=1 to 20 do
begin
p^:=i*5; { }
inc(p)
{ p
}
end
end.

16.4.

23416.
.
.

New Dispose
New Dispose .
, . -.
New , ,
. New
. : New(p). , .
New
.
Dispose ,
New ,
. : Dispose(p). p .
Dispose .
, .
Dispose . , ,
. ,
, - .
.
. ,
- , ,
. , ( ) -
. ,
.
16.3. New Dispose
var a,vasya : integer;
q,p
:^integer;
begin
new(p);
{ integer.
p }

16.4. 235
p^:=10;
q:=p;
new(p);

{ 10 }
{ }
{ .
, New
-
.
,
,
.
,

.
,
! }
p^:=3;
{ 3 }
dispose(p); { ,
, .
3 }
p:=q;
{ p
}
dispose(p); { ,
}
writeln(q^);{ , q
,
10,
.
.
! }
end.

, , , New, -
. , -.
,
,
(, Turbo Pascal Integer
2, 4). , .
,
,
( ).

23616.


.
. ,
, .
, , .
, !
, . ?
. , - .
, , ,
.
16.4.

type masA=array[1..30000] of integer;
masB=array[1..60000] of char;
var a : ^masA; {
, .
^array[1..30000] of integer; }
b : ^masB;
begin
{ ... - ... }
new(a);
{ }
{ .
, ,
a^[5] }
dispose(a); { ,
}
new(b);
{ }
{ }
dispose(b); { ,
}
end.

, (,

16.4. 237

), .
,
. Turbo Pascal
Delphi. , , , :
a:array of integer. ,
, setlength.
, . , setlength(a,20).

, :
?
, , ?!
!
. .
.
, , ,
. , ,
.
,
. :
!?
, - . , -, -
, -, ,
. , ,
,
! ,
, .
.

GetMem FreeMem
(
) GetMem FreeMem.
New -Dispose , ,
. New Dispose,

23816.
, , GetMem FreeMem
.
:
GetMem(<->,< >);
FreeMem(<->,< >);

- .
, . ,
sizeof.
; ,
.
GetMem-FreeMem
, . , ,
300 :
GetMem(a,SizeOf(integer)*300),
integer (a:^integer).


. , :
mas mas[10]. a .
.
, 16.5.
16.5.

var
a,p : ^integer;
i
: integer;
begin
GetMem(a,sizeof(integer)*300); {
}

16.4. 239
{ }
p := a; { ,

- }
for i:=1 to 300 do
begin
p^:=i*5; { }
inc(p)
{ p
}
end;
FreeMem(a,sizeof(integer)*300) { ,

}
end.


,
inc . -, .

. ,
:
q:=a; inc(q,9);

q^ .


, GetMem-FreeMem.
,
, .
1. ,
.
16.6.
var
a :^integer;
b :^integer;

{ }
{
}

24016.
pa,pb :^integer; { -
}
x : integer;
{ }
n : integer;
{ }
i : integer;
{ }
begin
n:=0;
{ }
readln(x);
{ }
while x<>0 do
{ ,
}
begin
inc(n);
{ }
{ 1 ,
. : }
GetMem(b,sizeof(integer)*n);
pb:=b;
{ pb
b }
{ a (n-1 )
b: }
if n>1 then
{ }
begin
pa:=a;
{ pa
a }
for i:=1 to n-1 do { }
begin
pb^:=pa^; { a b }
inc(pa); {
a }
inc(pb)
{
b }
end
end;
{ x
pb^:=x;
b }
{ , a: }
FreeMem(a,sizeof(integer)*(n-1));
{ a b: }
a:=b;
readln(x)
{ }
end
end.

, , , .
-

16.4. 241

.
, , ,
. -
, , 8 ,
16 . 7 ( )
. 2 , .
16.7.
var
a :^integer;
b :^integer;

{ }
{
}
pa,pb :^integer; { -
}
x : integer;
{ }
n : integer;
{ ,
}
k : integer;
{ }
i : integer;
{ }
begin
n:=1;
{ }
k:=0;
{ }
GetMem(a,sizeof(integer)); { }
readln(x);
{ }
while x<>0 do
{ ,
}
begin
inc(k);
{ }
{ ,
}
if k>n then
{ }
begin
n:=n*2;
{ }
{ }
GetMem(b,sizeof(integer)*n);
{ a (k-1 )
b }
pa:=a;
{ pa
a }

24216.
pb:=b;

{ pb
b }
for i:=1 to k-1 do { }
begin
pb^:=pa^; { a b }
inc(pa); {
a }
inc(pb)
{
b }
end;
pb^:=x;
{ x
b }
{ , a }
FreeMem(a,sizeof(integer)*(k-1));
{ a b }
a:=b
end
else { a }
begin
{ pa
a }
pa:=a;
inc(pa,k-1);
pa^:=x
{ x }
end;
readln(x)
{ }
end
end.

1. var

.
.
2.
-.
3. , ,
, ,
^ ().

243

4. ( ) ,
^ -.
5. ,
-, ^ .
6. (
) New GetMem.
7. (
) Dispose
FreeMem.


1. ?
2. ?
3. -?
4. ,
-?
5. -
?
6. ?
7. , ?
8. :
var a:integer;
begin
{
a:=10;
{
new(p);
{
p^:=15;
{
dispose(p);{
writeln(a);{
end.
{

p:^integer;
0 }
1 }
2 }
3 }
4 }
5 }
6 }

a) a?

24416.
) , a?
) p^?
) , p^?

17

.


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

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

17.1. 247

data

data

data

data

data

.
nil. ,
, .
- (.17.1).

. 17.1.
type MyElement=record
data:< , >;
next:<
, >
end;

,
. ,
:
type MyElement=record
data:string;
next:^MyElement
end;

.
( -) ,
( ).
:
, .
.
17.1.
type
pElement=^Element; { ,
.


,
""
}
Element=record

24817. .
data : string;
next : pElement

{
.
}
{
}

var
pBegin : pElement; {
,

}

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

17.2.

.
(
) .

.
LIFO (last in first out,
). - . ,
. ,
, .
().
, ,
, . :

17.2. 249
type pStack=pElement;

, ,
, :
type pStack=^Stack;
Stack=record
data:string;
next:pStack
end;

, . .
:
var pTop:pStack=nil;

Top () p,
, .
pTop (nil). ,
( ).
,
.
( ), pTop
:
var pTop:pStack;
begin
pTop:=nil;

,
:
. .
: Push,
Pop.

(Push)
Push . ,
.

25017. .
. , Push
. Push .
, ,
.
,
.
:
procedure Push(chto:string);

chto , .
Stack , , , chto .
, (.17.2).
pTop

data
data
data

. 17.2. ,

,
. new, -
, .
(Stack).
pStack. ,
- . Push
pStack:
var p:pStack;

:
new(p);

17.2. 251

: - .

, ,
. chto:
p^.data:=chto;

, :
p .
, ^,
p^. data . ,
. : p^.data.
. ,
. - .
(..17.2), ,
pTop . ,
next :
p^.next:=pTop;

. - ?
(.17.3).
p

chto

pTop

data
data
data

. 17.3.
( )

, , (pTop) .

25217. .
, .
p. :
pTop:=p

:
17.2. Push ( )
procedure Push(chto:string);
var p : pStack; { }
begin
new(p);
{ }
p^.data:=chto; { }
p^.next:=pTop; { }
pTop:=p
{ }
end;

, Push, ,
. , .
, pTop
nil.
Push, ,
( ) - pTop, nil.
nil
. , Push
.

(Pop)
(Pop)
.
, . Pop
.
, .
,
. :
function Pop:string;

17.2. 253

, Pop,
.
pTop, :
Pop:=pTop^.data;

. : -,
, , , ,
. : dispose(pTop), ,
,
pTop ( next
) pTop:=pTop^.next.
, . ,
,
.
pTop, , .
, , ,
.
17.3. Pop ( )
function Pop:string;
var p : pStack; { }
begin
p:=pTop;
{ }
Pop:=p^.data; { }
pTop:=p^.next;{
}
dispose(p)
{ }
end;

(StackIsEmpty)
,
( ). ,
nil:

25417. .
17.3. StackIsEmpty ( )
function StackIsEmpty:boolean;
begin
StackIsEmpty := pTop=nil
end;

17.3.
.
, `
, .
17.4.

var x,a:integer;
{ ,
Push, Pop StackIsEmpty
( ) }
begin
write(' :');
readln(x,a);
while x>0 do { }
begin
Push(x mod a); {
}
x:=x div a
{ }
end;
while not StackIsEmpty do { }
write(Pop) {
}
end.

, ,
10.
, , 9.


.

17.3. 255

, .

,
, .
Pop ,
. , write(Pop)
x:=Pop, Pop;.
, , .

,
. pTop,
Push Pop.
,
(Push, Pop StackIsEmpty) - ,
.
17.1. , , .
( ) .
17.2. , N, N . ,
().
, .
17.3. , , .
(,
7 8 , ).
17.4. , , 100.
, ,

25617. .
() , .
.


, ,
.
LIFO . ,

(, -) ,
Push Pop .
.
,
. , ,

( ). ,
.
17.5.
const n=100; { }
var Stack:array[1..n] of string; {
}
Top:integer=0; { .
}
procedure Push(chto:string);
begin
if Top<n then { }
begin
Top:=Top+1;
{ }
Stack[Top]:=chto { }
end
else
{ -
. , ,
,
.
,
}
end;

257
function Pop:string;
begin
Pop:=Stack[Top]; { }
Top:=Top-1
{ }
end;
function StackIsEmpty:boolean;
begin
StackIsEmpty := Top=0
end;

, ,
, .
-
, ,
, .

1.
, ,
, .
2. .

.
3. . ,
, .
4.

.


1. ,
, ?
?

25817. .
2.

( ,
)?
3. .
4. ? ?
5. ? ?
6. :
Push(1);
Push(2);
Push(3);
Push(Pop+Pop);
Push(4);
Push(Pop*Pop);
write(Pop-Pop);

, (,
data , ,
)?

18

.

, ,
. ,
, .
,
,
.

18.1.

, , . FIFO (First In First
Out) (queue).

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

18.1. 261
1

. 18.1.

,

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

.
. .

. type pQueue=pStack.
, :
type pQueue=^Queue;
Queue=record
data:string;

26218. .
next:pQueue
end;


pBegin pEnd. p , , begin end.
var pBegin:pQueue=nil;
pEnd :pQueue=nil;

, nil.

18.2.
, : . .

(EnQueue)
EnQueue ( ).
, .
. , EnQueue
. EnQueue .
, ,
.
,
.
:
procedure EnQueue(chto:string);
chto , .

, .
. (
nil), (new(pEnd)),

18.2. 263

chto (pEnd^.data:=chto),
nil (pEnd^.next:=nil). ()
(pBegin:=pEnd).
, : new(pEnd^.
next). ,
: ,
.
(pEnd:=pEnd^.
next) . chto (pEnd^.
data:=chto), nil
(pEnd^.next:=nil).
:
18.1. EnQueue
( )
procedure EnQueue(chto:string);
begin
if pBegin=nil then { }
begin
new(pEnd);
{ }
pBegin:=pEnd;
{
}
pEnd^.data:=chto; {
}
pEnd^.next:=nil { nil }
end
else { }
begin
new(pEnd^.next); {

}
pEnd:=pEnd^.next; {
}
pEnd^.data:=chto; {
}
pEnd^.next:=nil { nil }
end
end;

26418. .
, ,
( ) . :
18.2. EnQueue
( ).

procedure EnQueue(chto:string);
begin
if pBegin=nil then { }
begin
new(pEnd);
{ }
pBegin:=pEnd
{
}
end
else { }
begin
new(pEnd^.next); {

}
pEnd:=pEnd^.next; {
}
end;
pEnd^.data:=chto; {
}
pEnd^.next:=nil
{ nil }
end;

(DeQueue)
DeQueue ( ).
, , :
function DeQueue:string;

,
.
,
,
. (DeQueue:=pBegin^.
data).

18.3. 265

,
. ,
. , , ,
, .
p:=pBegin;
DeQueue:=p^.data;
pBegin:=p^.next;
dispose(p);
18.3. DeQueue
( )
function DeQueue:string;
var p : pQueue;
{ }
begin
p:=pBegin;
{ }
DeQueue:=p^.data; {
}
pBegin:=p^.next;{
}
dispose(p)
{ }
end;

(QueueIsEmpty)
,
, ( ).
, nil.
18.4. QueueIsEmpty ( )
function QueueIsEmpty:boolean;
begin
QueueIsEmpty := pBegin=nil
end;

18.3.
, , , ,

26618. .
, .
, , ,
, , .
. , .
. , , , .
,
. , 50 .
, .
,
, .
,
. , -
( ) .
, .
, .
18.5. ,

{ ,
, EnQueue, DeQueue
QueueIsEmpty, pBegin pEnd
( ) }
var s:string[51];
ch:char;
min:integer;
begin
s:='';
{ }
min:=51; { }
repeat
read(ch); { }
if (ch<>' ')and(ch<>'.') then
{ }
s:=s+ch { }
else

18.3. 267
if s<>'' then { }
begin
if length(s)<min then {
}
min:=length(s);
EnQueue(s); { }
s:=''
{ "" }
end
until ch='.'; { }
while not QueueIsEmpty do
begin
s:=DeQueue; { }
if length(s)>min then { min }
writeln(s)
{ }
end
end.

, ,
. pBegin pEnd,
EnQueue DeQueue. ,
,
(EnQueue, DeQueue QueueIsEmpty)
- DeQueue
QueueIsEmpty EnQueue

.
18.1. , , .
,
.
18.2. , , .
, :

26818. .
(
), (
, ).


,
.
FIFO
, LIFO. ,
.

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

. ,
. ,
, .
,
, . iBegin iEnd (
).
, : ,
, .

18.3. 269

, . , ,
( n+1=1).
,
, .
, :
, , , ?
iBegin iEnd 1 n.
, ,
, iEnd 1 , iBegin.

. .
, ,
iEnd 1 iBegin.
iEnd 2 iBegin.
18.6.
const n=100; { }
var Queue:array[1..n] of string; {
}
iBegin:integer=1; {
}
iEnd:integer=n;
{
}
procedure EnQueue(chto:string);
begin
{ }
if (iBegin-iEnd+n) mod n<>2 then
begin
if iEnd<n then { }
iEnd:=iEnd+1
else
{ }
iEnd:=1;
{ }
Queue[iEnd]:=chto;
end
else
{ -
}
end;
function DeQueue:string;
begin

27018. .
DeQueue:=Queue[iBegin];
if iBegin<n then { }
iBegin:=iBegin+1
else
{ }
iBegin:=1
{ }
end;
function QueueIsEmpty:boolean;
begin
QueueIsEmpty := (iBegin-iEnd+n) mod n=1
end;

1 2.

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


1. ?
2. ?
3. ?

19

.

,
FIFO


LIFO
( ). ,
, -
/ .

19.1.

,
,
, .
, nil.

, .
17,
, :
type pListElement=^ListElement;
ListElement=record
data:string;
next:pListElement
end;

, 1, pBegin:
var pBegin:pListElement=nil;
.
- , .

19.2. 273

, .19.1.
,
. . ,
,
- .
.

. 19.1.

19.2.

,

.



PrintList ( ). ,
-,
, .

.
, ,
, while. .

, nil (
).

27419. .
19.1. PrintList

( )
procedure PrintList;
var p:pListElement; { -
}
begin
p:=pBegin;
{
}
while p <> nil do { }
begin
writeln(p^.data);{

}
p:=p^.next
{ -
}
end
end;

data
chto

data

data

data

PutInList ( ).
. ,
, .
, ,
. , , ,
.
,
().
(.19.2).

. 19.2.

19.2. 275

next
, ( ).
next , .
(
).
PutInList.
procedure PutInList(chto:string;
kuda:pListElement);
chto , ,
kuda.

,
, , .
. , .
:
.
,
. , , ,
.
kuda nil ( ,
).
:
19.2. PutInList

( )
procedure PutInList(chto:string; kuda:pListElement);
var p:pListElement; { - }
begin
if kuda=nil then
{ }
begin
new(p);
{ }
p^.next:=pBegin;{ }
pBegin:=p;
{
}
p^.data:=chto
{
}
end
else { }
begin

27619. .
new(p);
{ }
p^.next:=kuda^.next; {

, kuda }
kuda^.next:=p; {
kuda }
p^.data:=chto
{
}
end
end;

, , .
PutInList .


, , , , . ,

.
, .
, RemoveFromList (
) .
. . RemoveFromList
.
, :
, , , , .
, , .
next . . .
. ,
, next
. .
- .
, . , .

19.3. 277


:
, ,
. , , .
,
, , , nil.
19.3. RemoveFromList ( )
procedure RemoveFromList(gde:pListElement);
var p : pListElement;
{ }
begin
if gde = nil then { }
begin
p:=pBegin;
{ }
pBegin:=p^.next; {
}
dispose(p)
{ ,
}
end
else
{ }
begin
p:=gde^.next;
{
}
gde^.next:=p^.next; {
}
dispose(p)
{ ,
}
end
end;

, RemoveFromList
, .

19.3.
,

, .

27819. .
,
X Y. ,
X Y.

. -,
Y,
. next , Y,
. , Y
, .
,
next. -, ,
Y.
,
.
19.4. ,
X, Y
var x,y:string;
{ ,
PutInList ( ) }
p:pListElement; { }
begin
write(' X:');
readln(x);
write(' Y:');
readln(y);
p:=pBegin; { "p" }
if p = nil then {
}
begin
writeln(' ');
exit
end;
if p^.data = y then { X }
PutInList(y,nil); { Y }
while p^.next <> nil do {
}
begin
if p^.next^.data = x then { ,

19.3. 279
,
X }
begin
PutInList(y,p); { Y }
p:=p^.next
{ }
end;
p:=p^.next
{ }
end
end.

, , X, .
,
Y, X.
Y, .

,
, .
, -
.



, , ,
. ,
.
19.1.

28019. .

()
.

,

.

, ,
/ , .

, /
.
19.1. ,
(1020) . .
.
19.2. 19.1 , :
)
;
) ,
, ;
) , ;
)
;
) A B C,
, A B.

281

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


1. data ?
2. -
?
3. ?
4.
.

?
5. ?
, ?
?
6. / ?
?

20

( ) , ,
, .
, .

20.1.
, ,
, . ,
( ).

1.
,
. .
. ,
.

, ,
. ,
.
.
.

28420.
, () ,
. ( ) . , , .
? :
, ,
.
- .
.
: n! n .
.
: n!=(n1)! n.
: 1! = 1. , 4!
3!, 2!, 1!, (=1)
2! (=1 2), (=2)
3! (=2 3), (=6) , ,
4!(=6 4=24). .20.1.
, ,
, .
4!=3!*4

=6*4=24

3!=2!*3

=2*3=6

2!=1!*2

=1*2=2

1!=1

. 20.1.

, .
, , 1.
n! n . , integer. longint.

20.1. 285
20.1.
function Fact(n:integer):integer;
begin
if n=1 then
{ 1!,
}
Fact:=1
{ 1 }
else
{ n 1 }
Fact:=Fact(n-1)*n { }
end;

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

, , .
.
20.1. ,
n n- ( ,
,
).


,
, .
, ,
.
. , , .

28620.
.
,
. 2n ( n
).
, ,
3n .

20.2.
.
: , (n),
, , ( , .20.2).
. : 1) ; 2)

.
A

. 20.2.

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

20.2. 287

- .
,
, . ,
(n1) . ,
n1 , .
n1 . .
.
20.2.

procedure (
N { }
,
A { }
,
B { }
,
C { } :integer);
begin
if N = 1 then
(A, B)
else
begin
(N1, A, C, B);
(A, C);
(N1, C, B, A)
end
end;

, , . ,
- . ,
.
,
.
20.2. 20.2
,

, 5 . , 31 .

28820.

20.3.


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

.
. ,
. ,
,
while, ,
,
.
:
1) (
);
2) ( );
3)
4) .
20.3. :
, ;

function Sum:integer;
var x:integer;
begin
readln(x);
if x=0 then
Sum:=0
else
Sum:=x+Sum
end;

20.4. 289

20.3. ,
, 0,
.

.
. ,
.

20.4.

f(x) [a,b].
.
, [a,b] f(x)
. ,
.
.
f(x) . f(x)
, . , .
,
.
.
:
, ( )
( ).
20.3.
(
)
function Dichotomy(a,b,eps:real):real;
var c:real;
begin

29020.
c:=(a+b)/2;
if b-a<eps then
Dichotomy:=c
else
if f(a)*f(c)<0 then
Dichotomy:=Dichotomy(a,c,eps)
else
Dichotomy:=Dichotomy(c,b,eps)
end;

, f(x)
.
, while
a b. .

20.5.

n
k, , n 0
1, k .
,
n,
, k . ,
.
.
.
.
: 0, 1.
0, n1 k . 1, n1 k1 .
. ,
:
.
:
1 ( 0 1).

20.5. 291

:
. , . ,
0 1, ,
, . , -
, .
,
n.
, , , .
n ( , k)
,
.

. ,
,
. .
20.4.
n, k
var a:array[1..100] of integer; {
}
i,dlina:integer; {

}
procedure Rasstanovka(n,k:integer);
begin
if n=1 then { }
begin
a[n]:=k; { 0 1.
,
( k) }
for i:=1 to dlina do
write(a[i]); { }
writeln
end
else
begin
a[n]:=0; { n- "0" }

29220.
if n-1>=k then

{
}
Rasstanovka(n-1,k); {
n-1 k }
a[n]:=1; { n- "1" }
if k-1>=0 then {
}
Rasstanovka(n-1,k-1); {
n-1 k-1 }
end
end;
begin
dlina:=6;
Rasstanovka(dlina,3);
end.

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


1.
?
2. ?
3. ?

1
-

.1. -

()
, -,
(A:=B+C)

.
.
, .

- .


. .
,
();

()

, (

).

1. - 295

I=1,N.
,
(
) N .
I

1 N 1

.
1. - A B+C.
,
.
2. - ,
: I=3,N,2 I 3 N 2.
3.
: i ! 1, N .
4. , (
). , .
,
, .
5. ()
(). , .

Integer. . . .
1. . , , ,
, .
2. .
, ,
, .
3. .
.
4. ().
.
5. . 4-, 6-
8- . .

Real. . . .

6. .
( ) , ,
, .
7. ( ).
, .

298 2.
8. ( ).
( ,
, ,
), , .
9. .
( ), ( )
.
10. .
, , ,
.

Real.
11. :
x + 2, 5
2
- 3 sin 2x ;
) y = x 2 +
3x
1-x
) y = 5
) y =

2x - 3, 5
+ e x + 2 $ cos3 x;
8x 2
5x - 6
2

x - 3 + 2, 4

- 3ln

2
.
5x

12. :
3x + 5
) y = 2 x - 3
;

) y =

5
;
4 log x - 2 3 + x

) y =

2tg 2 2x - 1
.
4

13. (Real
Integer):
) 2-13 mod 7/3+sqr(4);
) abs(8-sqrt(2/0.5)+4 mod 3);
) 12*3 div 5/3.5+sqr(1).

Boolean. 299

Char. . . . 1
14. . , ASCII .
15. (,
). ,
(/).
16. . , :
; ; , ( ASCII)
; , ( ASCII) .
17. . ,
.
18. : ,
. .

Boolean.
19. , .
(), ,
.
,
, , :
) ;
) ;
) ;
) ;
) ;
) , ( );
upcase(x),
.
.

300 2.
) ;
) .
.

Boolean.
20. , ,
x :
)

21. , ,
x:
) [1; 1] [3; 5];
) [1; 1] [3; 5];
) [; 1] [2; 4] [5; + ].

If. . Min/max/
22. 2 .
.

For. 301

23. 3 .
.
24. 3 . .
25. .
(+1 , 1 ,
0 ).
26. 4 . .
27. . ,
.

If.

2832: a b, :
28. ax + b = 0.
29. ax2 + bx = 0.
30. ax + b 0.
31. a|x| = b.
32. ax2 + b 0.
33. ax4 + bx2 + = 0 a, b c, .

For.
34. 10 . .
35. 20- (1, 3, 5, 7, ).
36. 15 :
1,4, 7, 10, 13,
37. 30
+30.

302 2.
38. (
). , .
39. 20
: 1, 1, 2, 3, 5, 8, (
).

For.
40. 10 .
.
41. 10-
.
:

----------1
1
3
27
5
125
7
343
9
729

42. ( ).
:

----------------0
1
1
2
2
4
3
8
4
16
5
32

43. 2,4x2 + 5x3


2 2 0,5.
:
x
|
y
--------+-------2.0 | -22.6

While-Repeat. 303
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0

| -15.9
| -10.4
| -6.1
| -3.0
| -1.1
| -0.4
| -0.9
| -2.6

44. 5
,
.

For.
45. 10 .
.
46. 10 .
.
47. 10 .
, 3.
48. 10 .
, .
49. N.
, N,
13 7.

While-Repeat.
50. , . .
51. , ,
5. , 10.
52. ,
.
.

304 2.
53. A B.
A B,
( , ).
54. , . (
readln read; readln ).
55. . (
2 ).
56. . (
).

While-Repeat.
57. N (N > 1).

11 1 1 1 1

N : , , , , , , g
12 3 4 5 6
.
58. N (N > 1).

1 3 5 7 9 11

N : , , , , , , g
1 2 4 8 16 32
.
59. N (N > 1) x. N :
2, 4x, 6x2, 8x3, 10x4, f .
60. (0 < < 1) x (0 < x < 1,5). :
1 x x3 x5
x7
,
, f , .
, , ,
2 4 16 256 65 536
.

. 305

.
:
61.

62.

63.

64.

65.

66.

.
:
67.

68.

69.

70.

71.

72.

306 2.

. , ,
/
(, 20 ):
73. :
2, 5, 8, 11,
74. :
2, 4, 8, 16, 32,
75. :
1, 3, 7, 15, 31,
76. .
77. .
78. . , (5, 1, 3, 8) ( ) (5 1, 1 3, 3 8).
4, 2, 5 .
(4 + 2 + 5)/3 3,67).
79.
.
80. ,
2, .
81. .
82.
.
83. ,
.

.
(, 20 ):
84. .
85. (
(1,2, 3, 4, 5, 6, 7, 8, 9, 10) (2, 1, 4, 3, 6,
5, 8, 7, 10, 9)).

. 307

86. (). .
87.
().
.
88. . ,
( (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
(5, 4, 3, 2, 1, 10, 9, 8, 7, 6)).
89. ( (1, 2, 3,
4, 5, 6, 7, 8,9, 10) (6, 7, 8, 9, 10, 1, 2, 3,
4, 5)).
90. 1 20 ( ).
, .
91. k ().
. k
.

.
,
.
(, 20 ):
92. .
93. .
94. .
95. . ,
.
96.
.

308 2.

.
(, 20 ):
97. , .
98. , .
99. , ,
( ).
100. , (
).
101. , .
102. ,
.
103. , .

.
(, 20 ):
104. .
105. ,
.
106. , .
107. , .
108. .
109. ,
( ).
110. , , .


111. ,
20 Hello!

. I 309

112. ,
,
, .
113. , , 13 3.
114. ,
99.
115. , ,
,
.
116. ,

( , ).

. I
117. . .
118. . .
119. . ( , ).
120. . Masha Irisha.
121. . .
122. . ,
.
123. , (
,
). ,
, .

310 2.

. II
( integer,
real) .
124. , .
, .
125. . ,
.
126. , , ( 7 ).

(, ).
127. , ,
( ). ,
, .
128. , , ( ).
, , .
129. , , . .

. I
130. ,
.
131. sign ( : +1,
0 1).
132. , X, Y.
133. , .
134. , .

. III 311

135. , , .

. II
136. ,
.
137. , , .
138. , , 10, .
139. , .
140. , ( ).
141. , , .

. III
, :
142. , .
143.
.
144. .
145.
.
146. ( ).
147.
.

312 2.
148. ( ( =1)
, ).

:
149. .
150. .
151. .
.
152.
( ).
:

1
2
3
4
5

2
1
4
3
5

153. ,
begin.
154. , .
155. .
156. ,
.
157. , .
158. ,
.
159. ,
.
160. ,
end ( / ).

313

161. (, )
, begin
end. , . , begin
end .
162. ,
. .
:
.


,
. .
163. (1020) ( 15+15). .
164. .
.
165. ,
.
.
166. . .
167.
, .
.
168. (12, 34, ).
.
169.
50 , .
.
170. , ,
, ,
, .. .

314 2.

171. .
.
172. .
.
173. . ,
.
174. . , .
175. , .
176. N-
k- . N k , ( N=3 k=2: 000, 001, 010,
011, 100, 101, 110, 111).
177. N
. N , 2 9, (
).
178. . , . : 4 = 3 + 1 = 2 + 2 = 2 + 1 + 1 = 1 + 1 + 1 + 1.


2-

.
.
.
.
.
.
.

14.11.10. 6090/16. . . . 21. 3000.


, 194044, -, . ., 29.
005-93, 2;
95 3005 .

-, . , www.pareto-print.ru


, ,
,

/ . , . ., . 29
./: (812) 7037373, 7037372; email: sales@piter.com
. , ., . 2/1, . 1, 6
./: (495) 23438-15, 97434-50; e-mail: sales@msk.piter.com

., . 169; ./: (4732) 396170


email: piterctr@omch.ru
. , . 11; ./: (343) 3789841, 3789842
mail: office@ekat.piter.com

. , . 13; .: (8312) 412731


email: office@nnov.piter.com
. , . 36; .: (383) 363-01-14
: (383) 3501979; email: sib@nsk.piter.com
//

. , . 26; .: (863) 2699122, 2699130


mail: piterug@rostov.piter.com

. , . 33; 223; .: (846) 2778979


e-mail: pitvolga@samtel.ru

. , . 12, 10; .: (1038057) 751-10-02


758-41-45; : (1038057) 712-27-05; -mail: piter@kharkov.piter.com

., . 6, . 1, 33; .: (1038044) 4903569


: (1038044) 4903568; mail: office@kiev.piter.com

. , . 34, 2; ./: (1037517) 201-48-79, 201-48-81


mail: gv@minsk.piter.com

, .
: (812) 703/73/73. E/mail: fuganov@piter.com
.
: / (812) 703/73/72, (495) 974/34/50
.: (812) 7037373.
mail: kozin@piter.com
: www.piter.com; .: (812) 703-73-74
ICQ 413763617

!



.


./: (4232) 238212
email: bookbase@mail.primorye.ru

,
.: (3952) 200917, 241777
email: prodalit@irk.ru
http://www.prodalit.irk.ru

, , . , . 1
.: (4212) 360665, 339531
email: dkniga@mail.kht.ru

,
./: (3952) 252590
email: kkcbooks@bk.ru
http://www.kkcbooks.ru

,
.: (4212) 328551, : (4212) 328250
email: postmaster@worldbooks.kht.ru
,
.: (4212) 394960
email: zakaz@booksmirs.ru


, , . , . 3
.: (8182) 654134, 653879
email: marketing@avfkniga.ru
, , . , . 4
.: (4732) 267777
http://www.amital.ru
, ,

./: (4012) 215628, 656568
email: nshibkova@vester.ru
http://www.vester.ru
, ,
, .15
.: (846) 3312233
email: chaconne@chaccone.ru
, , . , . 58
.: (4732) 512893, 470081
email: manager@kmsvrn.ru


, , . , 424
./: (87934) 69309
email: rossy@kmw.ru

,
. , . 86
./: (3912) 273971
email: bookworld@public.krasnet.ru
, 
.: (383) 3361026
: (383) 3361027
email: office@topkniga.ru
http://www.topkniga.ru

, ,

.: (843) 2723455
email: tais@bancorp.ru

,
. , . 12
./: (343) 3581898, 3581484
email: domknigi@k66.ru
,
. , . 1
./: (343) 228-10-70
e-mail: igm@lumna.ru
http://www.lumna.ru
,
. , . 124
.: (351) 2477403, 2477409, 2477416
email: zakup@intser.ru
http://www.fkniga.ru, www.intser.ru

?
!
?
?
? ,

?
!


!

www.piter.com/ePartners

www.piter.com,
,

( www.piter.com)
!
.
10% ,
, - c
. ,
, 5%
.
, , 500 ,
. Web.Money.
:
http://www.piter.com/book.phtml?978538800282
http://www.piter.com/book.phtml?978538800282&refer=0000
, 0000


WWW.PITER.COM


:
: www.piter.com
: postbook@piter.com
: (812) 703/73/74
: 197198, /, / 127,

ICQ: 413763617

:

.
.
,
.
.
: . Webmoney USD E-Gold, MoneyMail, INOCard, RBK Money (RuPay),
USD Bets, Mobile Wallet .
, ,
.
.
.
e-mail.
:
, , , , , email;
, , , , , ,
, ;
, , .

Вам также может понравиться