Академический Документы
Профессиональный Документы
Культура Документы
C/C++
-
-
2005
681.3.06
. .
C/C++ . .: -, 2005.
288 : .
ISBN 5-94157-029-5
C/C++,
/, ,
, , ,
,
, , .
,
.
C/C++
,
.
681.3.06
:
ISBN 5-94157-029-5
. ., 2001
, "-", 2001
//.
switch
for
do while
while
II.
III.
//.
switch
/*
do while
while
2
2
3
3
4
8
11
12
20
20
27
28
28
37
40
41
46
51
54
62
....68
71
237
237
237
238
238
238
239
239
239
239
239
240
241
241
241
241
IV
absjabs
acos, asin, atan, asinl, acosl, atanl
cos, sin, tan cosl, sin/, tan!
exp, expl
pow, powl
sqrt
rand
srand
atof
atoi, atol
gcvt
itoa, Itoa, ultoa
sprint/
-
print/.
scan/
puts
gets
putch
getch
cputs
cprint/
textcolor
textbackground
gotoxy
clrscr
window
/open
/print/.
/scan/
/gets
/puts
/error
/eo/
/close
strcat
strcpy
strlen
242
242
243
243
243
243
244
244
244
244
245
245
245
245
246
246
246
247
247
248
248
248
249
249
249
250
250
251
251
252
252
252
252
253
253
254
254
254
255
255
255
255
255
255
strcmp
strlwr
256
256
strupr
256
strset
strchr.
arc
bar
256
257
257
257
257
bar3d
circle
drawpoly
ellipse
getmaxx, getmaxy
gefx, gety
graphresiilt
grapherrormsg.
initgraph
line
lineto
linerel
moveto
moverel
outtext
outtextxy
pieslice
putpixel
rectangle
sector
setcolor
setfillstyle
setlinestyle
settexstyle
delay
sound
nosound
258
259
259
259
260
260
260
261
261
261
262
262
262
263
263
263
264
264
265
265
266
267
267
268
269
269
269
270
271
271
274
275
275
278
279
,
, ,
, . ?
, , , ,
. , ,
, .
, ,
, , ,
, .
.
.
:
.
,
, ,
,
, .
C++
.
. ,
, .
C++ Windows, DOS,
: ,
DOS,
.
? (
, )
Windows,
Microsoft Visual C++ Borland C++ Builder.
,
, , .
^
DOS 51 -
C/C++
,
. ,
.
,
. ,
.
,
, .
, .
:
, ;
;
.
,
, .
.
I.
, , :
;
, . ,
C++
, ,
;
:
.
:
D
( );
C++ ,
, , Summa summa
;
C++ : i n t
() f l o a t ();
.
/-^"+-
1. ,
.
2. ,
.
3. ,
.
4. ,
.
5. ,
.
6. ,
.
7. ,
, ,
.
8. ,
,
.
, , :
, "
";
, ++
,
, ,
, x=x+dx x+=dx, i = i + l
i++;
,
. -
I.
. , ,
i n t , 327 67,
=+1
-32768;
,
.
9. ,
-1,5.
10. ,
summa .
11. ,
.
12. ,
counter.
13.
1 2.
14.
= -2,7-0,23x^-1,4.
15. ,
X , dx.
16.
( 405,9 ).
17.
(
1066,8 ).
18.
.
19.
: s = -a-h,
; h .
C/C++
20. +
h, b
: s = ; .
21.
:
s-n-r^.
11,
.
"
.9 = I'Tl-rQl + r)
V = r^ h
C'R' -'
23.
.
24.
.
V = ---.:-
4
S=
4--~
25.
.
26.
.
I.
v = n-h-(r;
-;)
,
i^
>.___
-
h
27.
.
28.
.
29.
,
.
30.
.
31.
,
.
32.
,
: ^ ^^ IL:I1-
33.
.
/-^+
34.
, ,
.
35.
,
, .
, , :
p r i n t f
;
p r i n t f
,
,
;
, %;
: %i
, % , %f
, , %n,mf
,
, ;
>
, : \
, \ t , \ " , \ \
\;
p r i n t f ,
p u t s ,
;
I.
D ,
,
,
Norton Commander,
:
printf(" <Enter>");
getch();
36. ,
.
37. ,
stdio.h.
38. ,
:
! !
,
.
. .
39. , b
( f l o a t )
, :
=
b =
40. h 1
( f l o a t ) ,
.
(^, ^),
().
41. ,
, ( i n t ) .
42.
, b .
.
10
C/C-i"^
43.
1 2.
,
, "".
, c p r i n t f cputs.
,
c p r i n t f cputs
\\.
, c p r i n t f c p u t s ,
t e x t c o l o r {).
textbackground ().
1
.
c l r s c r , t e x t c o l o r
textbackground,
# i n c l u d e <conio.h>
44. ,
:
,
.
,
, .
. .
45. , :
" , ",
(
: , ,
, , ,
, ).
.
I.
11
, , :
1
scanf;
scanf
, ,
;
: %i
, %
%f , %
, %s ;
,
scanf
. ,
.
46. ,
r a d i u s f l o a t .
47. ,
( f l o a t ) . ,
<Enter>.
48. ,
. ,
.
49.
,
.
50.
12
C/C-i-+
, .
,
: ,
.
, ,
:
G
, ,
;
, ;
, .
)
/
/
()
I.
13
51. .
(, ,
).
:
() -> 9
() -> 7 . 5
: 67.50 . .
52. .
(, ,
).
.
:
() -> 9
() -> 7.5
() -> 5
: 337.50 ..
53.
.
(,
, ).
^ .
:
() -> 9
() -> 7 . 5
() -> 5
: 90.00 . .
54. .
(, ,
).
14
C/C++
.
() <Enter>
-> 9 . 5
: 857.38 ..
55. .
(, ,
).
.
:
() -> 5
() -> 10
1570.80 . .
<Enter>
56. ,
.
(,
, ).
.
:
(.) -> 2 . 7 5
-> 5
(.) -> 0 . 8 5
-> 2
: 15.45 .
57. ,
.
(, ,
).
^ .
:
(.) -> 2.75
(.) -> 0.5
(.) -> 7
: 22.75 .
I.
15
58.
( ) .
(,
, ).
.
:
(.) -> 8.5
() -> 2.3
: 19.55 .
59. ,
.
(,
, ).
.
:
() -> 8.5
() -> 10
42.50 ..
60. ,
.
(,
, ).
.
( ) ()
-> 25 17
-> 30
: 106.25 ..
61.
,
.
(, ,
).
16
C/C++
,
.
:
() -> 15
() -> 20
: 8.57
62.
,
.
(,
, ).
.
:
() -> 15
()-> 2 7 . 3
( ): 42.30
63.
.
(, ,
).
.
:
() -> 36
() -> 1500
: 0.024 .
64.
, .
(,
, ).
.
:
( ) -> 120
I.
17
, 1
() -> 3.5
420 .
65.
( ).
: (); ,
100 ;
.
(, ,
).
.
() ->7
( 100 ) ->8.5
(.) ->.5
74.04 .
66. , ,
.
. ,
, .
.
() -> 1000
(.)-> 3.25
: 1000
: 3 25 = 205
17.56 /
<Enter>
67. .
(, ,
).
.
:
() -> 5.5
() -> 7
665.23 ..
18
C/C++
68.
.
(, ,
).
.
:
() ~> 5 . 5
() -> 7
: 431.97 . .
69. .
(, ,
).
.
,
( ).
.
<Enter>.
-> 7.5 2.5 3
56.25 ..
70.
(1 1066,8 ).
(,
, ).
.
-> 100
100 106.68
71.
(1 405,9 ).
(,
, ).
.
-> 5
5 2.05
72.
. (% ) () -
I.
19
.
(,
, ).
.
:
(.) -> 2500
() -> 30
() -> 20
: 41.10 .
: 2541.10 .
73.
, , ,
.
(, ,
).
( ) -> 150
150 2 . 30 .
74. ,
. ,
12.5 12 . 50 .
.
-> 2 3 . 6
2 3 . 6 . 23 . 60 .
75.
(1 405,9 ).
(,
, ).
.
<Enter>.
-> 3 . 5
3.5 (/) 1 420 .
76. ,
, .
-
20
C/C++
(, ,
).
.
( ):
1,1 -> -2 5
2,2 -> 1 7
, -> 5 -3
: 23.56 ..
if
, , :
i f
;
, if;
, e l s e , ,
,
, ;
,
;
i f .
77. , .
, ( ), -
I.
21
.
(,
, ).
.
,
<Enter>.
-> 12
. .
78. .
.
(, ,
).
.
:
() -> 3.5
() -> 7
! .
79. ,
.
,
, .
.
, ,
.
(.) -> 2.90
! 60
<Enter>
80. , ,
.
. , ,
.
, 2000, <Enter>
-> 2001
2000 -
<Enter>
22
/+-^
81.
, .
.
(, ,
).
.
:
() -> 15
()-> 2 7 . 3
(1 , 2 ) -> 2
: 9.68
82. .
,
, .
(, ,
).
<Enter>
-> 12 27 -10
:
1 = -25.551
2 = -28.449
83.
. 10% ,
1000 .
(,
, ).
<Enter>
-> 1200
10%
: 1080.00 .
I.
23
84.
. 3% ,
500 , 5% 1000 .
(, ,
).
.
<Enter>
-> 640
3%
: 620.80 .
85. . , .
(,
, ).
-?
<Enter>
-> 1705
, - 1703 .
86.
. ,
.
(, ,
).
?
<Enter>
-> 1939
.
87.
. .
.
(, ,
).
:
1.
24
C/C++
2.
3.
<Enter>
-> 3
.
.
88.
. .
.
(, ,
).
:
1. , -
2. -
3.
<Enter>
-> 1
.
: 2.
89. ,
. ,
, , ,
.
.
<Enter>.
-> 34 67
34 67
90. ,
, ,
"!" "
" .
(,
, ).
I.
25
6x7?
<Enter>
-> 56
. 6x7=42
91. ,
( 100), ,
"!" " "
.
(,
, ).
83-17?
<Enter>
->7
. 83-17=66
92. , ,
.
(, ,
).
<Enter>
-> 23
23 .
93. , ,
.
(,
, ).
<Enter>
-> 451
451 .
94.
20% ,
.
(, ,
).
.
:
( ) -> 3
26
C/C++
(1 , ... 7 ) ->
20%.
: 5.52 .
95. ,
,
.
: () 100.
(,
, ).
() (), <Enter>
->170 68
2.00 .
96. ,
. ,
, "
".
.
( 1 12)
-> 11
97. ,
: "
" , " " " " .
98. ,
( 1 999),
, "" . ,
12 , 21 . .
99. ,
( 1 99),
, "" .
, 5 , 41 . .
100. ,
.
, (, ,
).
I.
27
(, , ) -> 31 12
2000
!
!
1.1.2001
switch
, , :
switch
;
-
, case;
-
, case,
, d e f a u l t ;
-
( i n t ) (char) .
101. ,
,
, .
102. ,
(
, ).
.
(,
, ).
28
/+-*-
(.)
423
2.2
095
1,0
815
1.2
846
1,4
.
:
-> 423
( )-> 3
:
: 2.20 .
: .60 .
103. ,
, .
:
"1
+ - -2c + 777)mod7.
(^ + ^(13-1) + + _4_
+
_4_
d , ,
, ( I, 2, ...,
12), Y ,
. ,
, .
: 1 , 2
, ..., 6 , .
for
, , :
f o r
, ,
;
I.
29
- ;
- ( i n t )
.
104. ,
10 .
105. ,
.
.
.
1
2
3
4
5
6
7
8
9
10
1
4
9
16
25
36
49
64
81
100
106. ,
.
.
.
1
3
5
7
9
1
9
25
49
81
30
C/C++
107. ,
.
.
(,
, ).
.
-> 20
20 210
108. ,
.
.
(, ,
).
.
<Enter>
-> 12
12 156
109. ,
: 1, 3, 5, 7 ...
.
(,
, ).
: 1,3,5,7 ...
-> 15
15 330
. ,
: ^ + + ":; + 7"^"
.
(, ,
).
: 1+1/2-+-1/3+ ...
- -> 15
15 3.3182
111. ,
.
.
I.
31
1
2
4
8
16
32
64
128
256
512
1024
0
1
2
3
4
5
7
8
9
10
112. ,
. (
1 . , I
1, 8 40320).
.
,
-> 7
7 5040
113. ,
= -2,4X2+5JC-3 ~2 2, 0,5.
.
X
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
-22.60
-15.90
-10.40
-6.10
-3.00
-1.10
-0.40
-0.90
-2.60
32
C/C++
114. , 5
.
. , ,
.
. <Enter>
-> 5.4
-> 7.8
-> 3.0
-> 1.5
-> 2.3
: 4.00
<Enter>
115. ,
.
. .
.
-> 5
.
<Enter>
-> 5.4
-> 7 . 8
-> 3.0
-> 1.5
-> 2 . 3
: 4.00
<Enter>
116. ,
.
.
<Enter>
-> 12.3
33
I.
-> 15
-> 10
-> 5.6
-> 11.5
1 : 12.30 , : 12.30
2 : 27.30 , : 13.65
3 : 37.30 . : 12.43
4 : 42.90 . : 10.73
5 : 54.40 . : 10.88
<Enter>
117. ,
, .
.
. . ,
, .
.
-> 5
.
<Enter>
-> 5.4
-> 7.8
-> 3.0
-> 1.5
-> 2.3
: 5
: 4.00
: 1.5
: 7.8
<Enter>
118. ,
10 1 10,
.
.
*** ***
1 3 4 2 7 4 9 6 2
, .
3.9
34
C/C-f-i-
119. ,
1 10,
.
.
***
10
5
^^^^
10 4 2 5 8 1 7 7 3
, . 5.30
3 6 1 10 1 3 8 7 6
, . 5.50
2 2 5 4 2 2 1 .
10 , . 3.90
<Enter>
120. ,
, , 100 1
100 .
(, ,
).
<Enter>
( )
-> 16.50
()
100
200
300
400
500
600
700
800
900
1000
(.)
1,65
3.30
4.95
.60
8.25
9.90
11.55
13.20
14.85
16.50
121. ,
=\:\. -4 4,
0,5.
122. ,
>^|x-2|+|x+l|. -4 4,
0,5.
I.
35
123. ,
, , 7.
.
7x2=14
7x3=21
7x4=28
7x5=35
7x6=42
7x7=49
7x8=56
7x9=63
124. ,
.
.
1 2 3 4 5 6 7 8 9
1 1 2 3 4 5 6 7 8 9
2 2 4 6 8 10 12 14 16 18
3 3 6 9 12 15 18 21 24 27
4 4 8 12 16 20 24 28 32 36
5 5 10 15 20 25 30 35 40 45
6 6 12 18 24 30 36 42 48 54
7 7 14 21 28 35 42 49 56 63
8 8 16 24 32 40 48 56 64 72
9 9 18 27 36 45 54 63 72 81
10
10
20
30
40
50
60
70
80
90
125. ,
: 1-1/3+1/5-1/7+1/9-...
/4 (
, /4).
126.
()=5^-+2 .
127. .
128. ,
. "",
.
.
36
/-^+
-
- -
-
-
-
-
- -
-
-
-
-
-
129. ,
.
.
255 <Enter>
-> 49
4 9 00110001
<Enter>
130. .
10 :
10 "", 9 8 "", 7
6 "", 6 "".
.
.
*** ***
<Enter>.
5x3=15
7x7=49
1x4=4
4x3=12
9x4=36
8x8=64
7x8=52
! 7x8=56
4x7=28
3x5=15
2x5=10
: 9
: .
I.
37
131.
100. 10
,
, . .
.
: 10
"", 9 8 "", 7 6 "",
6 "".
.
.
.
<Enter>
75-4=71
35-9=29
! 35-9=26
14-1=13
6-5=1
37-19=28
! 37-19=18
53-14=39
94-87=7
90-16=74
4-2=2
89-41=48
: 8
:
132. ,
" ", ,
, ,
.
do while
, , :
do while
;
38
C/C++
do while ,
, while,
;
1 while
;
do while
,
;
do while , . .
;
do while, ,
,
, .
133. ,
,
.
(,
, ).
.
.
.
-> 45
-> 23
-> 15
->
: 3
: 83
: 27.67
134. ,
( ).
(, ,
).
I.
39
.
. .
-> 56
-> 75
-> 43
->
: 75
135. ,
( ).
(, ,
).
.
.
.
-> 12
-> 75
-> 10
-> 9
-> 23
->
: 9
136. , >1 ,
.
. ,
, .
<Enter>
-> 45
45 .
137.
.
,
.
138. , ""
1 10 5 -
40
/-^-+
.
(, ,
).
" ".
"" 1 10.
5 .
<Enter>
-> 5
.
-> 3
! !
139. -,
,
, .
while
, , :
do while
;
G while ,
, while,
;
G while
;
G while
,
;
while , . .
,
;
I.
41
D while, ,
,
, .
140. ,
= 2:^-5:-8 -4 4.
0,5.
141. , ""
.
"" ,
1-1/3+1/5-1/7+1/9-...
7/4.
(, ,
).
-> .001
0.001000 3.143589
502 .
142. ,
.
(,
, ).
, , :
,
, ;
1
;
;
() . -
42
C/C++
. /-1,
;
;
, #define;
,
(for, while);
, . .
.
143. ,
5 ,
.
.
.
<Enter>
[1] -> 12
[2] -> 0
[3] -> 3
[4] -> -1
[5] -> 0
3
144. ,
.
(,
, ).
.
(5 )
<Enter>
-> 23 45 -5 12
1 : -5
I.
43
145. ,
.
.
146. ,
.
(, ,
).
(10 )
<Enter>.
-> 23 45 - 5 12 -2 30 64
: 184
: 7
: 23.86
147. ,
.
(,
, ).
min max .
(10 )
->12 10 5 7 15 4 10 17 23 7
: 4
: 23
. min max : 10.36
148. , (
) .
.
(, ,
).
.
-> 12
-> 10
-> 16
-> 18
~> 17
-> 16
-> 14
: 1 4 . 7 1 .
44
/-^+
149. , ,
.
.
150. , ,
.
151. , ,
.
152. , ,
.
153. ,
.
154. , ("")
.
155. ,
,
.
, , ,
.
.
,
(5 ) -> 1 3 5 7 9
,
(5 ) -> 2 4 8 10
1 2 3 4 5 6 7 8 9 10
<Enter>.
156. , ,
, .
157. ,
, .
.
.
*** ***
() <Enter>.
<Enter>
I.
45
-> 175
-> 170
-> 180
-> 168
-> 170
->
: 172.6
2 .
158. ,
.
159. ,
.
160. ,
.
.
. ,
, .
.
:
-> 12
-> 10
-> 7
-> 1
12
10
7
1
<Enter>
161. ,
.
162. ,
.
(
).
C/C-^-f-
46
.
<Enter>
-> 5 -7
-> 1 3
5.00 -7.00
1.00 3.00
22.00
163. ,
, .
164. , ,
""
.
"" ,
,
(.
).
2 9 4
7 5 3
6 1 8
13
2
3
16
10
5
12
7
6
9
1
14
15
4
, , :
;
C++ ;
, ,
: ' \*;
, ,
-
I.
47
,
:
chcu: *mes[] ={" 1"," 2", ... ,
","} ;
, scanf
, gers ,
<Enter> ' \ ' .
165. ,
.
(,
, ).
?
, <Enter>
->
, !
166. ,
, .
g e t c h O .
167. ,
.
168. , . "" :
, .
169. ,
.
, , .
(,
, ).
<Enter>.
.
-> 1
: 1 : 4 9
-> 2
48
C/C+'t-
: 2 : 50
->
: : 235
->.
170. ,
(
127).
.
15, 16 31 . .
171. ,
(, upcase
).
(,
, ).
<Enter>
-> C++,
Windows
, :
C++, WINDOWS
172. ,
.
173. , ,
.
(,
, ).
<Enter>
-> 2 3 . 5
.
174. , ,
.
175. , ,
.
176. , ,
.
177. ,
. -
I.
49
(
).
<Enter>
-> 11101010
11101010 234
<Enter>
178. ,
.
179. ,
( 2 10).
.
-> 67
-> 2
67 100011 2
180. ,
.
181. ,
NoOiN\02..0^N\^, N\ , ^
:
(+) .
(,
, ).
,
, 4+5-3-5+2, <Enter>
-> 9-5+4+2-6
: 4
<Enter>
182. ,
.
, -,
,
50
/+-^
.
:
, , .
. , ,
.
,
.
-> 3 5 9
-> 12 9 8
-> 5 4
-> 2
-> 3 1 2
-> 10 10 5
-> 9 3
-> 3 4
-> 2 4
-> 5 1 4
, 1998 .
1
12
9
29
8
2
25
10
10
5
3
9
18
3
17
4
3
5
9
4
5
15
5
4
13
3
7
12
4
2
8
1
4
10
5
9
0
2
8
10
3
2
1
178
155
114
96
92
80
68
61
46
37
51
I.
. , ,
.
. .
,
.
1 <Enter>.
<Esc>.
-> 123 : . :
-> 456 : 1. :
-> 654 : 2. : 2
-> 657 : 2. : 2
-> 658 : 3. : 3
*** ! ***
<Enter> .
184. -,
.
.
.
.-..
.-.
..-.
-..-
-...
.-.
...-.
.
..."
-.
-.-.
-....
.
..
.-..
..
..-
-.-.-.-
, , :
1
. , . . ,
, ;
52
C/C++
(
)
,
;
,
,
.
185. , .
.
186. ,
, .
187. ,
: >, <
=,
188. ,
, .
(
).
: ,
- 1 .
189. , ^.
b .
190. Procent,
.
191. "" ,
.
192. Dohod,
. : ,
() ( ).
193. g l a s n , 1,
, ,
, .
I.
53
194. sogl, 1,
, ,
, .
195. ,
, .
196. ,
.
. , ,
: 2 , 1
, . ,
.
, - 1 .
197. , ,
. ( )
.
198. , ,
.
.
199. ,
.
200. frame,
.
.
201. ,
.
, .
<Backspace>. <Enter>
.
202. ,
.
,
54
C/C-I-+
. ,
.
<Backspace>.
<Enter>
.
203. , "21".
.
, , :
,
16- ;
.
(0,0),
(639,479);
(, , ),
.
:
//
#include <graphics.h>
#include <conio.h>
#define PATHTODRIVER "c: W b o r l a n d c W b g i W "
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult{);
55
I.
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>")
getch();
return;
//
closegraph(); //
}
204. , .
205. ,
. (
).
C/C++
56
206. , .
207. , .
)
)
208. ,
.
I.
57
209. ,
100 .
210. ,
50 .
211. , -
100 ,
.
212. ,
.
213. ,
.
214. ,
.
215. ,
.
216. ,
.
C/C++
58
217. ,
.
218. ,
.
219. ,
. :
( , ,
setcolor).
220. ,
.
^ I.
59
111, ,
.
222. ,
.
223. ,
.
224. , .
.
225. , .
, ,
.
/-^+
60
116. ,
.
5.0
4.0
3.0
2.0
1.0
0.0
0.00
0.5 1.0
1.5
2.0
2.5
3.0
3.5
227. ,
}^0,5:2-4:-3.
-15 5; ~ 0,1.
,
.
228. ,
.
229. , .
, .
, ,
.
230. ,
,
. -
.
.
, .
61
I.
:
-> 10
-> 15
-> 7
-> 1
45. 5%
^^^
30
30 3%
3.0%
t^l^*wf
231. , ,
( ) .
( : ,
, )
. .
- 34.3%
- 31.4%%
\^t^
I
- 22.
I - 11.4%
62
/+-^
232. ,
.
.
1
233. ,
, .
234. ,
=2 sin(jc) ^/^.
, , :
,
, -
FILE;
, , ,
: ,
, (
);
I.
63
,
. ferror
,
, (f open);
f scanf, fprintf;
( f close).
235. ,
( :) numbers.txt 5
.
, , Norton Commander,
. ,
.
236. ,
A:\numbers.txt .
, 10
.
237. ,
A:\numbers.txt.
238. ,
, A:\numbers.txt.
239. ,
( ),
, C++.
,
.
240. ,
: phone.txt , ,
, . , .
(, , ) .
.
64
C/C++
->
->
-> 234-84-37
.
<Enter>
241. ,
A:\phone.txt. .
.
<Enter>
~>
->
-> 234-84-37
.
->
1 - >
~> 5 5 2 - 1 8 - 4 0
.
->
<Enter>
242. ,
(A:\phone.txt) .
.
, '
.
.
.
<Enter>.
<Enter>
->
.
-> 1
578-12-45
244-34-02
->
I.
65^
243. ,
" " "
".
, .
*** ***
1.
2.
3.
->
Enter>
244. . ,
.
.
. ,
:
.
:
,
80%
,
60%, 60%.
(Ni i- , Ki,
),
( ,
, ).
1
Ni Ml
N2 2
66
C/C-i"!-
Nk
3 2
2 2
3 2
, -.
, -
.
.
.
.
<Enter>
:
1.
2.
3.
-> 2
:
1.
2.
-> 2
I.
67
:
1. , -.
2 . , .
. .
->2
!
<Enter>
245. ,
C++,
. ,
,
.
246. ,
,
.
(, ,
.
***
:
1 ;
2 ;
3 .
1 3 <Enter>
-> 1
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
12.7
25.4
38.1
50.8
63.5
76.2
88.9
101.6
114.3
127.0
68
0/0+-^
, , :
,
;
,
().
247.
, .
248. ,
.
249. ,
, .
(
R2) .
69
I.
250. ,
249 .
.
25L ,
, . ,
, 90
: , .
,
"" .
.
c_n_z] d
252. ,
.
. ,
.
.
1
float , ; //
float s;
//
2
float funt; //
float kg;
//
3
float
int
int
float
summa ;
srok;
stavka;
dohod;
//
//
//
//
()
()
5
float rl, 2; //
float s;
//
7
float
int
float
int
float
float
CenaTetr;
KolTetr;
CenaKar;
KolKar;
CenaLin;
Suirana ;
11
++;
//
//
//
//
//
//
'
72
C/C++
12
c o u n t e r -= 2;
14
: = - 2 . 7 * * * + 0.23** -
1.4;
15
X += d x ;
16
kg = f u n t * 0 . 4 0 5 9 ;
21
/ / __1, "",
/ / math.h
S = _1 * * ;
22
//
//
S
V
_1, "",
math.h
= 2*M_PI*r*(h+r);
= M_PI * r * r * h ;
24
float ;
float V, s;
//
//
V = (3*M_PI*r*r*r)/4; // _1
S = 4* PI*r*r;
// math.h
34
float ctetr, cobl, ckar; // ,
int
ntetr, nkar;
// -
float summ;
// cy^da
II.
73
II ,
//
= n t e t r * (ctetr+cobl) + nkar*ckar;
37
#inclucle <stdio.h>
#include <conio.h>
void main ()
{
38
//
#include <stdio.h>
#include <conio.h>
void mainO
{
printf(" ! !\n");
printf(" -\");
printf(" ,\");
printf(" .\\");
printf("
..\");
printf("\\ <Enter>");
getch; //
}
39
printf("a=%5.3f
b=%5.3f
c=%5.3f", a, b , c ) ;
40
printf(" = %3.2f = %3.2f \", h, 1);
/+-^
41
printf("a=%i
b=%i
c=%i", , b , ) ;
42
printf("a=%i\nb=%i\nc=%i\n",
, b , ) ;
44
//
#include <conio.h>
void main()
{
textbackground(BLUE); //
textcolor(LIGHTGRAY); //
clrscrO;
//
cprintf(" \\");
cprintf(" .\\");
cprintf (" \")
cprintf(" , .\n\n\r")
cprintf("
..\\\")<
c p r i n t f ( " \ \ < E n t e r > " ) ;
getch();
}
45
//
#include <conio.h>
void main ()
{
clrscr;
textcolor(RED);
cprintf(" \n\r");
textcolor(LIGHTRED); //
cprintf(" \n\r");
textcolor(YELLOW);
cprintf(" \n\r");
textcolor(GREEN);
cprintf(" \n\r");
textcolor(LIGHTBLUE)/
II.
cprintf(" \n\r");
textcolor(BLUE);
cprintf(" \n\r");
textcolor(MAGENTA);
cprintf("!\n\r");
textcolor(LIGHTGW^Y);
cprintf("\ <Enter>");
getch()/
47
scanf("%f", &u);
scanf("%f", &:r);
48
scanf("%f %f", &u, &r)
49
//
float , h; //
float v;
//
//
printf(" :\");
printf(" ->");
scanf("%f", &);
printf(" ->");
scanf("%f\ &h);
50
float ctetr, ckar; //
int ntetr, nkar;
//
printf(" ( )\");
printf(" ->");
scanf("%f %i", &ctetr, &ntetr)
printf{" ->");
scanf("%f %i", &ckar, &nkar)
75
76
/-^+
51
//
#include <stdio.h>
#include <conio.h>
void main()
{
float l,w; //
float s;
//
printf(" ");
printf(" :\");
printf(" (.) -> " ) ;
scanf("%f", &1);
printf(" (.) -> ") ;
scanf("%f", &W);
S = 1 * w;
printf(" : %10.2f ..\n", s ) ;
printf("\\ <Enter>");
getch();
}
53
//
#include <stdio.h>
#include <conio.h>
void main()
{
float l,w,h; // ,
float s;
//
printf(" ");
printf("");
printf(" :\");
printf(" () -> " ) ;
scanf("%f", &1);
printf(" () -> " ) ;
scanf("%f", &w);
printf(" () -> " ) ;
II.
scanf("%f", &w);
s = (l*w + l*h + w*h)*2;
printf(" : %6.2f .\",);
printf("\\ <Enter>");
getch();
}
55
//
#include <stdio.h>
tinclude <conio.h>
void mainO
{
float r,h,v; // ,
printf(" \");
printf(" :\");
printf(" () -> " ) ;
scanf("%f", &);
printf(" () -> " ) ;
scanf("%f", &h);
V = 2*3.1415926*r*r*h;
printf(" %6.2f .", v ) ;
printf("\ <Enter>");
getch();
56
//
#include <stdio.h>
tinclude <conio.h>
void mainO
{
float kar,tetr; //
int nk,nt;
//
float summ;
// }
printf(" \");
77
78
/0++ ^
printf(" :\");
printf(" (.) -> " ) ;
scanf("%f", &tetr);
printf(" -> " ) ;
scanf("%i", &nt);
printf(" (.) -> " ) ;
scanf("%f", &kar);
printf(" -> " ) ;
scanf("%i", &nk);
suirim=tetr*nt + kar*nk;
printf(" : %6.2f .", summ);
printf(" <Enter>")/
getch();
60
//
//
#include <stdio.h>
#include <conio.h>
#include "math.h"
// sin M_PI - ""
void main ()
{
float a,b; //
float u;
// , ^
float s;
//
printf(" ");
printf(" " ) ;
printf("() -> " ) ;
scanf("%f%f", &, &b);
printf(" " ) ;
printf("(.) -> " ) ;
scanf ("%f", S,u);
/* s=a*h/2, a - , h - .
h - h=b*sin(u).
sin ,
1 . = 180/pi, pi - "").
II.
S = a*b*sin(u*M_PI/180)/2;
printf(" : %6.2f K B . C M " , S ) ;
printf("\\ <Enter>");
getch();
}
61
// ,
// .
#include <stdio.h>
#include <conio.h>
void main()
{
float rl,r2; //
float ;
//
printf(" \");
printf(" \");
printf(" :\");
printf(" () -> " ) ;
scanf("%f",&rl);
printf (" () -> " ) ;
scanf("%f",&r2);
r=rl*r2/(rl+r2);
printf (" : % .2 f ",);
printf(" <Enter>");
getch();
}
65
//
#include <stdio.h>
#include <conio.h>
void main ()
{
float rast; //
79
80
C/C++
float pot; // 100 .
float ; //
float suirati; //
printf(" ");
printf(" () ~> " ) ;
scanf("%f",&rast);
printf(" ( 100 .) -> " ) ;
scanf("%f",&potr);
printf(" (.) -> " ) ;
scanf("%f",&cena);
summ = 2 * potr/100 * rast * cena;
printf(" ");
printf (" %6.2f py6.",suimi) ;
printf("\\ <Enter>");
getch();
66
//
#include <stdio.h>
#include <conio.h>
void main()
{
float s;
//
float t;
//
float v;
//
int min;
//
int sek;
//
float ts; //
printf(" \");
printf(" () -> " ) ;
scanf("%f", &s);
printf(" (, )~> " ) ;
scanf("%f", &t);
min = t;
sek = (t - min) * 100;
ts = min * 60 + sek;
IL
V = (s /1000) /
81^
(ts / 3600);
68
//
#include <stdio.h>
#include <conio.h>
#include "math.h" // M_PI - ""
void main()
{
float r; //
float h; //
float s; //
printf(" ");
printf(" :\");
printf(" () - > " ) ;
scanf("%f", &);
printf(" () - > " ) ;
scanf("%f", &h);
s = 2*M_PI*r*r i-2*M_PI*r*h;
printf(" %6.2f . \", s);
printf("\ <Enter>");
getch();
70
//
#include <stdio.h>
#include <conio.h>
82
C/C-f-f-
v o i d main
{
float v; //
float ; //
printf(" ");
printf(" ->");
scanf("%f", &V);
= v*1.0668;
printf("%6.2f - %6.2f \", v,);
printf("\ <Enter>");
getch();
72
//
#include <stdio.h>
#include <conio.h>
void mainO
{
float suram;
//
int srok;
//
float stavka; //
float dohod;
// no
printf(" ");
printf(" :\");
printf(" (.) -> " ) ;
scanf("%f", &suiran) ;
printf(" () -> " ) ;
scanf("%i", &srok);
printf(" () -> " ) ;
scanf("%f", &stavka);
dohod = suirati * s t a v k a / 3 6 5 / 1 0 0 * s r o k ; / / 365 - -
/ /
suiran = summ + dohod;
p r i n t f ("
p r i n t f (": %9.2f " ,
\n") ;
dohod);
II.
printf(" : \
%9.2f py6.\n",suram);
printf("\ <Enter>");
getch();
}
73
// , ,
/ / ,
#include <stdio.h>
tinclude <conio.h>
void mainO
{
int mill; //
int h;
//
int m;
//
printf(" ( ) -> " ) ;
scanf("%i",&min);
h = (int)min / 60;
m = min % 60;
printf ("%i . - %i 4ac.%i ", min, h, m) ;
printf("\ <Enter>");
getch();
}
74
//
#include <stdio.h>
tinclude <conio.h>
void mainO
{
float f;
//
int r;
// ()
int ;
// ()
printf(" \"),
83
84
C/C++
printf("
~> " ) ;
scanf("%f",&f);
r -
(int)f;
= f * 100 - r*100;
printf("%6.2f . - %i . %i .\", f,
, ) ;
printf("\ <Enter>");
getch();
}
77
//
#include <stdio.h>
tinclude <conio.h>
void mainO
{
float a,b,c; // ,
printf(" ");
printf(" , " ) ;
printf(" <Enter>");
printf("-> " ) ;
scanf("%f%f", &a, &b);
if (b != 0)
{
= a / b;
printf(" %5.2f %5.2f ", a, b ) ;
printf(" %5.2f", c ) ;
}
Ise {
printf("! ");
printf("!\");
}
printf("\ <Enter>");
getch();
II.
85
78
//
#include <stdio.h>
#include <conio.h>
void main()
{
float rl,r2; //
float s;
//
printf(" :\");
printf(" () -> " ) ;
scanf("%f",&rl);
printf(" () -> " ) ;
scanf("%f",&r2);
if (rl > 2)
{
S = 2 * 3.14 * (rl - 2);
printf(" %6.2f .\", s);
}
else
{
printf("! ");
printf(" .\");
}
printf("\ <Enter>");
getch();
}
79
//
#include <stdio.h>
#include <conio.h>
void main()
{
float t;
//
int ts;
//
int min;
//
int sek;
//
, 1.25
'
86
C/C++
printf(" (.) -> " ) ;
scanf("%f", &t);
min = t; // t float, -
// ""
sek = (t - min) * 100;
if (sek > 60)
{
printf("!");
printf(" 60");
}
else
{
ts = min * 60 + sek;
printf("%i %i = %i ", min, sek, ts);
}
printf("\ <Enter>");
getch();
80
// ,
#include <stdio.h>
#include <conio.h>
void mainO
{
int year;
int r;
// year 4
printf(" , 2001, <Enter>");
printf("->");
scanf("%i", &year);
r = year % 4;
if ( r )
printf("%i ~ \n", year);
else
printf("%i ~ \", year);
printf("\ <Enter>");
getch();
II.
81
//
#include <stdio.h>
#include <conio.h>
void mainO
{
float rl,r2; //
float ;
//
int t;
// :
//
1 - ;
//
2 -
printf(" \")
printf(" :\");
printf(" () - > " ) ;
scanf("%f", &1);
printf(" () - > " ) ;
scanf("%f", &2);
printf(" " ) ;
printf("(1-, 2-) - > " ) ;
scanf<"%i", &t);
if (t == 1)
= rl + 2;
else = 1*2 / (1+2);
printf(" : %6.2f \", );
printf("\ <Enter>");
getch();
82
//
#include <stdio.h>
#include <conio.h>
#include "math.h"
void main ()
{
float a,b,c;
//
float xl^x2;
//
float d;
//
87
88
C/C-^-t-
printf("\* *\");
printf(" ")/
printf(" <Enter>");
printf("-> " ) ;
sc^nf("%f%f%f", &a, &b, &c);
//
d = b*b - 4*a*c;
//
if (d < 0)
printf(" ");
else {
xl = (-b + sqrt(d))/(2*a);
x2 = (-b - sqrt(d))/(2*a);
printf(" : xl=%3.2f x2=%3.2f\n", xl, x2);
}
printf("\ <Enter>");
getch();
84
//
#include <stdio.h>
#include <conio.h>
void main()
{
float surnm; //
printf(" ");
printf(" <Enter>");
printf("-> " ) ;
scanf("%f", &suinni) ;
if (suirai < 500)
printf(" .\n");
else {
printf(" " ) ;
if (summ > 1000) {
printf("5%\n");
summ = 0.97 * summ;
}
else {
printf("3%\n");
II.
suirau = 0.97 * summ;
};
85
//
tinclude <stdio.h>
#include <conio.h>
void mainO
{
int year;
//
printf("\ -?\");
printf(" <Enter>");
printf("-> " ) ;
scanf("%i", &year);
if (year == 1703)
printf(".");
else {
printf(" , " ) ;
printf ("- 1703 ");
}
printf("\ <Enter>");
getch();
}
87
//
tinclude <stdio.h>
tinclude <conio.h>
void mainO
{
int otv; //
89
90
0/0-^-+
printf(" :\");
printf("1. \");
printf("2. ");
printf("3. \");
printf(" <Enter>");
printf("-> " ) ;
scanf("%i", &otv);
if (otv == 2)
printf(".");
else {
printf(" A n " ) ;
printf(" .\n");
}
printf("\ <Enter>");
getch();
}
89
//
#include <stdio.h>
#include <conio.h>
void main ()
{
int a,b; //
printf(" " ) ;
printf(" <Enter>")/
printf("->");
scanf("%i%i", &a, &b);
if (a == b)
printf(" ");
else if (a < b)
printf("%i %i\n", a, b ) ;
else printf("%i %i\n", a, b ) ;
printf("\ <Enter>");
getch();
II.
91
90
//
#include <stdio.h>
#include <conio.h>
#include <stdlib.h> // srand
#include <time.h>
// time
void main()
{
int ml, m2, p; //
int otv;
//
time_t t;
// -
//
srand((iinsigned) time(&t));; //
// .
ml = rand % 9 +1;
// randO 9
// 8
2 = rand % 9 +1;
= ml * m2;
printf(" %ix%i ?\n", ml, m2);
printf(" <Enter>");
printf("-> " ) ;
scanf("%i", &otv);
if (p == otv)
printf(".");
else
printf(" .\n%ix%i=%i", ml, m2, p) ;
printf("\ <Enter>");
getch();
}
92
//
#include <stdio.h>
#include <conio.h>
void mainO
{
int n; //
92
/-^-^
printf(" <Enter>");
printf("-> " ) ;
scanf("%i", &n);
printf(" %i " ) ;
if (n % 2 == 0)
printf(".");
else
printf(".");
printf("\\ <Enter>");
getch();
94
//
// ,
#include <stdio.h>
#include <conio.h>
void mainO
{
int time;
//
int day;
//
float surnma; //
printf(" ");
printf("");
printf(" :\");
printf(" " ) ;
printf("( - ) - > " ) ;
scanf("%i", &time);
printf(" ");
printf(" (1-,..,7-) - > " ) ;
scanf("%i", &day);
suinma ~ 2.3 * time;
// 2.3 .
if (day == 6 I I day == 7)
{
printf(" 20%\n");
summa = summa * 0.8;
};
printf(" : %3.2f .\n",summa);
II.
93
95
//
#include <stdio.h>
#include <conio.h>
void main()
{
float w;
//
float h;
//
float opt; //
float d;
//
printf(" , ,\");
printf(" () (), <Enter>");
printf("->");
scanf("%f%f", &h, &w);
opt = h - 100;
if (w == opt)
printf(" !");
else
if (w < opt)
{
d = opt - w;
printf(" %2.2f .", d ) ;
}
else
{
d = w - opt;
printf(" %2.2f .", d ) ;
}
printf(" <Enter>");
getch();
94
C/C-f-+
96
//
#include <stdio.h>
#include <conio.h>
void mainO
{
int month; //
puts(" ( 1 12)");
printf("-> " ) ;
scanf("%i", smonth);
if (month < 1 && month > 12)
printf(" 1 12");
else if (month >= 3 && month <= 5)
printf("");
else if (month >= 6 && month <= 8)
printf("");
else if (month >= 9 && month <= 11)
printf("");
else printf("");
printf("\\ <Enter>");
getch();
}
98
// ""
#include <stdio.h>
#include <conio.h>
void mainO
{
int n; //
int r; // n 100 (
// ), - 10 ( )
printf(" , 999 -> " ) ;
scanf("%i", &n);
printf("%i ", n ) ;
//
II.
I/ , 11 14
if ( > 100)
= % 100;
else = ;
// -
if ( >= 11 && <= 14 )
printf("\");
else
{
= % 10;
// -
if ( >= 2 && <= 4 )
printf("");
else if ( == 1)
printf("\");
else printf("\");
}
printf("\ <Enter>");
getch();
100
//
#include <stdio.h>
#include <conio.h>
void mainO
{
int day;
int month;
int year;
int last; // 1,
int ;
// ,
// year 4
printf(" () " ) ;
printf(" ");
printf("( ) -> " ) ;
scanf("%i%i%i", &day, &month, &year);
95
96
C/C++
l a s t = 0;
i f (month ==2) {
if ((year % 4) !== 0 && day == 28) last = 1;
if ((year % 4) == 0 && day == 29) last ^ 1;
}
else if ((month == 4 || month == 6 ||
month = = 9 1 1 month ==11)
&& (day == 31))
last = 1;
else if (day ===31)
last = 1;
if (last == 1) {
printf(" !\n");
day = 1;
if (month ==12) {
month = 1;
year++;
printf("C !\n");
}
else month++;
}
else day+-i-;
printf(" %i %i %i",day,month,year);
printf("\ <Enter>");
getch();
}
101
//
#include <stdio.h>
#include <conio.h>
void main()
{
int nd; //
puts(" (1..7");
printf("->");
97
11.
scanf("%i", &nd);
switch (nd)
{
puts("");
case
put s("");
case
put
s("");
case
puts("");
puts("");
case
puts("");
case
puts ("e");
case
break;
break;
break;
break;
break;
break;
breaJc;
102
//
//
tinclude <stdio.h>
#include <conio.h>
void mainO
{
int kod;
//
float cena; //
int dlit;
//
float suram; //
printf(" ");
printf(" " ) ;
printf(" :\");
printf(" ( - ) - > " ) ;
scanf("%i", &dlit);
puts(" ");
puts("Baoco\t432") ;
puts("MocKBa\t\t095");
puts("MypMaHCK\t815");
puts("CaMapa\t\t846");
printf("->");
scanf("%i", &kod);
98
/-*"*-
printf(": " ) ;
switch (kod)
{
case 432: puts("");
cena = 2.2;
break;
case 95: puts("");
cena = 1;
brecJc;
103
//
#include <stdio.h>
#include <conio.h>
void main()
{
int day,month,year; // , ,
int ,;
int m;
int d;
//
//
//
II.
puts("\nOnpe ");
puts(" : .");
puts(", 5 12 2001");
printf("->");
scanf("%i %i %i", &day, Smonth, &year);
if (month == 1 I I month == 2)
year;
//
/ /
m = month - 2;
//
if (m <= 0) m += 12; //
// m -
= year / 100;
= year - *100;
d = (day+(13*m-l)/5-by+y/4+c/4-2*c+777)%7;
switch (d)
{
case 1: puts ("") ; breaJc;
case 2: puts("");
break;
3:
case
put s (" ") ;
;
case 4: puts("")<
breaJc;
case 5: puts("")
break;
case 6: puts("")<
break;
case 0: puts("");
}
printf("\ <Enter>\n");
getch();
IPS
//
#include <stdio.h>
#include <conio.h>
void main()
{
99
100
C/C'i'-^'
i n t X = 1;
int ;
int i;
/ /
//
//
printf(" \");
printf ("
\");
printf("\tKapa\n");
printf ("
\") ;
for (i = 1; i <= 10; i++)
{
= x*x;
printf("%3i\t%4i\n", X, y ) ;
X += 2;
}
printf ("
\n") ;
printf("\ <Enter>");
getch();
107
'
//
#include <stdio.h>
#include <conio.h>
void mainO
{
int n;
// -
int summ; //
int i;
//
printf(" \");
printf(" -> " ) ;
scanf("%i", &n);
sujxm = 0;
for (i = 1; i <= n; i++)
summ = summ+i;
printf(" %i ",n);
printf(" %i", summ);
//.
p r i n t f ( " \ \ < E n t e r > " ) ;
getch();
}
109
// : 1,3,6,9 ...
#include <stdio.h>
#include <conio.h>
void mainO
{
int e;
//
int n;
// -
int suitim = 0 ; //
int i;
//
printf(" : " ) ;
printf("1,3,6,9, ...\");
printf(" -> " ) ;
scanf("%i", &);
= 1;
for (i = 1; i <= n; i++)
{
suinm += e;
e += 2;
}
printf(" %i %i", n, suram);
printf("\ <Enter>");
getch();
}
110
// 1+1/2+1/3+ ...
#include <stdio.h>
#include <conio.h>
void mainO
{
int n;
// -
101
102
C/C'^^^^
float i;
// .
// int, 1/i
//
float elem;
//
float suram = 0 ; //
printf(" ");
printf("1+1/2+1/3+..");
printf(" - ");
printf("-> " ) ;
scanf("%i",&n);
suram = 0;
for (i = 1; i <= n; i++) {
elem = 1 / i;
summ += elem;
}
printf(" %i", n ) ;
printf(" %6.3f",summ);
printf("\ <Enter>");
getchO ;
}
111
//
#include <stdio.h>
#include <conio.h>
void mainO
{
int n; // "
int x; // 2 n
printf(" ");
X - 1;
II.
103
printf("\ <Enter>");
getch();
}
113
//
#inclucle <stdio.h>
#include <conio.h>
tdefine
LB -2.0
#define
2.0
tdefine
DX
0.5
void main
{
float ,;
int ;
int i;
//
//
//
//
//
//
// -
//
= ( - LB)/DX +1;
X = LB;
printf ("
\n");
printf("
X
I
y\n");
printf ("
\n") ;
for (i = 1; i<=n; i++)
{
= -2.4*x*x+5*x-3;
printf("%6.2f j %6.2f\n" ,K ,y);
X += DX;
}
printf ("
\n") ;
printf("\ <Enter>");
getch();
}
104
C/C-f-f-
116
// ,
/ /
#include <stdio.h>
#include <conio.h>
#define L 5 //
void main ()
{
float a;
int n;
float sum;
float sred;
//
//
//
//
printf(" \");
printf(" <Enter>");
sum = 0;
for (n = 1; n <= L; n++)
{
printf("-> " ) ;
scanf("%f", &a);
sum += a;
printf(" : %i ", n ) ;
printf(": %6.2f\n", sum);
sred = sum / L;
printf(", : %6.2f\n", sred);
printf("\ <Enter>");
getch();
}
117
//
//
// ,
#include <stdio.h>
#include <conio.h>
II,
105
v o i d main
{
float ;
int ;
float sum;
float sred;
float min;
float max;
int 1;
//
//
//
//
//
//
//
printf(" .\");
printf(" ->");
scanf("%i", &n);
printf(" .\n");
printf(" <Enter>");
printf("->");
scanf("%f",&); //
//
// , :
min = ; //
max = ; //
sum = ;
//
for (i = 1; i < n; i++)
{
printf("->");
scanf("%f", &a);
sum += a;
if (a < min) min = a;
if (a > max) max = a;
}
sred = sum / n;
printf(" : %i\n", n ) ;
printf(" : %6.2f\n", sred);
printf(" : %6.2f\n", min);
printf(" : %6.2f\n", max);
printf("\ <Enter>");
getch();
106
C/C-'-f-
119
//
//
#include <stdio.h>
#include <conio.h>
#include <stdlib.h> // srand rand
#include <time.h>
#define L 10
#define N 3
//
//
void main
{
int r;
int sum;
float sred;
int i,j;
time_t t;
//
//
//
//
//
//
srand((unsigned) time(&t));; //
//
for (i = 1; i <= N; i++)
{
//
printf(" : " ) ;
sum = 0 ; // !
for (j = 1; j <= L; j++)
{
r = randO % 10 +1 ;
printf("%i ", r);
sum += r;
}
sred = (float)sum / L; //
printf("\nCpe..: %3.2f\n", sred);
}
printf("\ <Enter>");
getch();
II.
107
121
// 1 =|1
#include <stdio.h>
#include <conio.h>
#include "math.h"
#define
#define
#define
LB -4 //
//
4 //
//
DX 0.5
void main
{
float ,;
int ;
int i;
//
//
// -
//
123
// 7
#include <stdio.h>
#include <conio.h>
void mainO
{
int m; // ,
// ()
106
C/C^^'^
int ;
int ;
//
//
m = 7;
printf(" %i\n", m ) ;
for (n = 1; n<=9; n++)
{
p = * n;
printf("%ix%i=%i\n", m, n, p ) ;
}
printf("\ <Enter>");
getch();
}
124
// -
#include <stdio.h>
#include <conio.h>
void mainO
{
int i,j; //
printf("
");
//
for (j = 1; j <=10; j++) // -
//
printf("%4i",j);
printf("\n");
for (i = 1; i <=10; i++)
{
printf("%4i",i);
for (j - 1; j <= 10; j++)
printf("%4i",i*j);
printf("\n");
}
//
//
printf("\ <Enter>");
getch();
II.
109
125
// ""
// 1 -1/3 + 1/5 - 1/7 + ...
#include <stdio.h>
tinclude <conio.h>
void main()
float x;
//
int n;
//
float suirati;
//
int i;
//
// (-1000)
// , ""/4
printf(" 1 -1/3 + 1/5 - 1/7 + . . . \ " ) ;
printf(" - ->" ) ;
scanf("%i", & n ) ;
suitim = 0 ;
126
//
// ( for)
#include <stdio.h>
#include <conio.h>
110
C/C-f-f-
v o i d main ()
{
float a,b;
float dx;
float s;
int ;
float ;
float ;
int i;
//
//
//
//
//
//
printf(" ");
printf(" -> " ) ;
scanf("%f", &);
printf(" -> " ) ;
scanf("%f", &b);
printf(" -> " ) ;
scanf("%f", &dx);
n = (b - a) / dx + 1;
X = a;
s = 0;
for (i = 1; i<=n; i++)
{
= x*x + 2 ; //
S += y*dx;
X += dx;
}
printf(" : %6.3f", s);
printf("\ <Enter>");
getch();
}
127
//
#include <stdio.h>
#include <conio.h>
void main()
{
float a,b;
//
float dx;
//
II.
float s;
int ;
float ;
float 1,2;
int i;
111
//
//
//
//
printf(" \")/
intf(" ");
intf(" -> " ) ;
scanf("%f", &);
printf(" -> " ) ;
scanf("%f", &b);
printf(" -> " ) ;
scanf("%f", &dx);
n = (b ~ a) / dx;
X = a;
s = 0;
for (i == 1; i <==n; i++)
{
yl = x*x + 2 ;
// -
X += dx;
2 = * + 2 ;
// -
S += (1 + y2)*dx/2;
}
printf(" : %6.3f", s ) ;
printf("\ <Enter>");
getchO ;
129
//
#include <stdio.h>
#include <conio.h>
void main()
int dec;
int v;
int i;
//
//
//
112
C/C-f"^
printf(" ");
printf(" 255")/
printf (" <Enter>");
printf("~> " ) ;
scanf("%i", &dec);
printf(" %i ",
dec) ;
V = 128; // ()
for (i = 1; i <== 8; i++)
{
if (dec >= v)
{
printf("1");
dec -= v;
}
else printf("0");
V = V / 2; //
}
printf("\\ <Enter>");
getch();
}
130
//
#include <stdio.h>
#include <conio.h>
#include <stdlib.h> // srand rand
#include <time.h>
void main ()
{
int numbl, nu]nnb2; //
int res;
//
int otv;
//
int kol = 0 ;
//
int i;
//
time_t t;
// -
//
II.
printf("\*** ***\");
printfC <Enter>");
srand((unsigned) time(&t));; //
//
for (i = 1; i <= 10; i++) // 10
{
numbl = rand()%7 + 2 ; / / 2 9
nuinb2 = rand()%7 + 2 ;
res = numbl * nurnb2;
printf("%ix%i=", numbl, numb2);
scanf("%i",&otv);
if (otv == res)
koH-+;
else printf("B ! %1%1=%\...\n",
numbl, numb2, res) ;
}
printf(" : %i\n", kol);
printf(" : " ) ;
switch (kol)
{
case 10: puts("5"); break;
9: puts("4"); break;
case 8: puts("4"); break;
case 7: puts("3"); break;
default: puts("2"); break;
}
printf("\ <Enter>");
getch();
}
131
//
tinclude <stdio.h>
#include <conio.h>
tinclude <stdlib.h> // srand rand
#include <time.h>
113
114
C/C-^-f-
// 2 99
void main()
{
int nuitibl, nuinb2; //
int op;
// :
/ / - , 1 -
char zop;
// - "" ""
int res;
//
int otv;
//
int kol = 0 ;
//
dint buf;
// 12,
/ / , numbl<nunib2
int i;
//
tiine_t t;
// -
//
printf(" ");
printf(" <Enter>");
kol = 0;
srand((unsigned) time(&t));; //
//
for (i = 1; i <- 10; i+-b)
{
//
nurobl = rand % LEVEL;
numb2 = rand % LEVEL;
op = rand()%2;
if (op == 0)
{
res = numbl + nuinb2;
zop = '+';
}
else
{ //
zop = '- *;
i f (nuinbl < numb2)
// 2 99
//
/ / numbl nuinb2
II.
115
buf = 2;
nuinb2 == numbl;
nurnbl = buf ;
}
res = 1 - nuinb2;
}
printf("%i%c%i=", numbl, zop, numb2); //
//
scanf("%i", &otv)
if (otv == res)
kol++;
else printf(" . %i%c%i=%i\n",
nunuDl, zop, nuinb2, res) ;
}
printf(" : %i\n", kol);
printf(" :\n");
switch (kol)
{
case 10 puts("5") break
case 9
puts("4") bireak
case 8
puts("4") break
case 7
puts("3") break
default puts("2") break
}
printf("\ <Enter>");
getch();
132
//
#include <stdio.h>
#include <conio.h>
// delay
#include "dos.h"
void mainO
{
int inin,sec;
// ,
clrscrO;
//
_setcursortype (_NOCURSOR); //
printf(" , ");
for (min = 0; min <= 2; min++)
{
116
C/C-f-f-
for (sec = 0; sec <= 59; sec++)
{
delay(1000);
// 1000 itis
gotoxy(l,3);
// 1~ 1-
printf("%i:%2i", min, sec);
if (kbhitO) break;
}
if (kbhitO) break;
}
_setcursortype (_NORMALCURSOR);
getchO; // ,
printf("\ <Enter>");
getch();
133
//
//
#include <stdio.h>
#include <conio.h>
void mainO
{
int a;
// ,
int n;
//
int s;
//
float m; //
s - 0;
n = 0;
printf("\ ");
printf(" .\");
printf(" . .\");
do {
printf("-> " ) ;
scanf("%i", &a);
if (a > 0)
{
s +- a;
n++;
}
II.
} w h i l e ( > 0 ) ;
printf(" : %i\n", ) ;
printf(" : %i\n", s);
iti = (float) s / n;
printf(" : %3.2f", m) ;
printf("\\ <Enter>");
getch();
134
//
/ /
#include <stdio.h>
#include <conio.h>
void mainO
{
int a; //
int m; //
puts("\ ");
puts(" .");
puts(" . .");
m = 0;
do {
printf(""> " ) ;
scanf("%i", &a);
if (a > m) m = a;
} while (a > 0);
printf(" : %i", m ) ;
printf("\ <Enter>");
getch();
135
//
//
#include <stdio.h>
#include <conio.h>
117
118
/-*"*-
v o i d main
{
int ;
int min;
//
//
printf("\nOnpe ");
printf(" .\");
printf(" . .\");
printf("-> " ) ;
scanf("%i", &);
min = ;
//
while ( > 0)
{
if ( < min) min = ;
printf("-> " ) ;
scanf("%i", &a);
}
printf(" :
");
printf("%i\n", min);
printf("\ <Enter>");
getch();
136
// ,
#include <stdio.h>
#include <conio.h>
void mainO
{
int n; //
int d; //
int r; // n d
printf (" --> " ) ;
scanf("%i", &n);
d = 2;
//
do {
= n % d;
.
if ( != 0) d++;
}
while ( != ); // d
if (d == n)
printf("%i - " ,n);
else printf("%i - " ,n);
printf("\\ <Enter>");
getch();
138
// " "
linclude <conio.h>
#include <stdlib.h> // srand
linclude <time.h>
void mainO
{
int comp;
//
int igrok; //
int n;
//
time_t t;
// -
//
120
C/C-f-+
textcolor(RED+BLINK);
cprintf("\\ !");
}
else
{
textcolor(GREEN);
cprintf("\\ .);
cprintf (" %d",coinp);
}
textcolor(LIGHTGRAY);
cprintf("\\ ...");
getch();getch();
}
140
//
#inclucie <stciio.h>
#include <conio.h>
void main()
{
float x,dx;
float 1,2;
float ;
1 = -4;
2 = 4;
dx = 0.5;
X = 1;
printf ("
printf (" X I
printf ("
while ( < 2) {
= * + 2;
printf("%3.2f
X += dx;
}
printf ("
//
//
//
\") ;
\");
\") ;
1 %3.2f\n", X, ) ;
\n") ;
printf("\ <Enter>");
getch ();
}
II.
121
141
// ""
#include <stdio.h>
#include <conio.h>
void main()
{
float p;
//
float t;
//
int n;
//
float el; //
= 0;
= 1;
el = 1; //
printf(" -> " ) ;
scanf("%f", &t);
printf(" %f\n",t);
while (el >= t )
{
el = (float) 1 / (2*n -1);
if ((n % 2) == 0)
p -= el;
else p += el;
n4-f;
}
p = p*4;
printf(" %f %f\n", t, p ) ;
printf (" %i ", n ) ;
printf("\ <Enter>");
getch();
142
//
// ( )
iinclude <stdio.h>
#include <conio.h>
void mainO
122
/-*"^
int 1,2;
int nod;
int ;
// ,
//
// 1 2
printf("\ " ) ;
printf(" .\");
printf(" " ) ;
printf(" <Enter>");
printf("-> " ) ;
scanf("%i%i", &nl, &2);
printf(" %i %i - ", nl, 2);
while (nl % 2)
{
= nl % 2; //
nl = 2;
2 = ;
}
nod = 2;
printf("%i\n", nod);
printf("\ <Enter>");
getch();
}
143
//
// ( )
#include <stdio.h>
#include <conio.h>
#define SIZE 5 //
void mainO
{
int a[SIZE];
int n = 0;
int i;
//
// - ~
//
printf("\ .\n");
printf(" " ) ;
printf(" <Enter>\n");
144
//
#include <stdio.h>
#include <conio.h>
#define HB 5
//
void mainO
{
int a[HB]; //
int min;
//
int i;
//
printf(" ");
printf(" ");
printf("%i , <Enter>\n", );
printf("-> " ) ;
for (i = 0; i < HB; i4-+)
scanf("%i",&a[i]);
min = 0 ; // , -
// cpaBHPiM -
for (i = 1; i < HB; i++)
if (a[i] < a[min]) min = i;
printf(" : " ) ;
printf("a[%i]=%i ", min+1, a[min]);
printf("\ <Enter>");
getch();
123^
124
C/C-t-^
145
//
// ( )
#include <stdio.h>
#include <conio.h>
#define HB 5
//
void mainO
{
int a[HB];
//
int *min;
//
int *p;
//
int i;
printf("\ ");
printf(" ,\");
printf("%i , <Enter>\n", );
printf("-> " ) ;
= ;
for (i = 1; i <= ; 1++)
scanf("%i", ++);
min = a;
//
= + 1;
//
// - ^>
for (i = 2; i <= ; i++)
{
if (*p < *min) min = p;
P++; / /
}
printf(" : %i\n", *min);
printf("\ <Enter>");
getch();
}
148
// ( )
#include <stdio.h>
#include <conio.h>
//.
125
v o i d main
{
// -
char *day[] = {"","","",
"","","",""};
float t[7];
//
float sum;
//
float sred;
//
int i;
printf(" :\");
for (i = 0; i <= 6; i++)
{
printf("%s->", day[i]);
scanf("%f", &t[ij);
sum += t[i];
}
sred = sum / 7;
printf(" : %2.1f", sred);
printf("\ <Enter>");
getch();
}
149
//
tinclude <stdio.h>
#include <conio.h>
tdefine HB 5
void mainO
{
int m[HB]; //
int obr;
//
int found; //
int i;
printf(" ");
printf(" %i ", );
printf(" <Enter>\n");
printf("->");
126
/-*-*-
f o r ( i = 0 ; i < ; i++)
scanf("%i", &m[i]);
printf(" ( )->");
scanf("%i", &obr);
//
found = 0;
i == 0;
//
do {
if (m[i] == obr )
found = 1 ;
//
else i++;
//
} while (!found && i < );
if ( found )
printf(" %i", i+1);
else
printf(" ");
printf("\ <Enter>");
getch();
150
// ,
#include <stdio.h>
#include <conio.h>
#define 5
void mainO
{
int a[HB];
//
int k;
//
int ok;
// 1 -
printf(", \n");
printf(" \");
printf(" (%i ", );
printf(" ) <Enter>\n");
for ( = 0; < ; k-f+)
scanf("%i", &[]);
11.
= 0;
ok = 1;
do {
if (a[k] > a[k+l])
ok = 0;
k++;
} while ( < HB-1 && ok);
printf(" " ) ;
if ( !ok )
printf(" " ) ;
printf(" ");
printf("\ <Enter>");
getch();
151
// ,
#include <stdio.h>
tinclude <conio.h>
#define HB 5 //
void mainO
{
int a[HE]; //
int obr;
// ()
int n;
// - ,
//
int i;
//
printf(" (%i ", );
printf(" )\");
printf("->");
for (i = 0; i < HB; i++)
scanf("%i",&a[i3);
printf(" ->");
scanf("%i", &obr);
n = 0;
for (i 0 ; i < HB; i++)
if (a[i] == obr) n++;
f7
128
C/C-^-f-
if ( )
printf(" %i %i ",
, ) ;
else printf(" ");
printf(" <Enter>");
getch();
153
//
#include <stdio.h>
#include <conio.h>
#define SZ 5 //
void main 0
{
int a[SZ]; // of integer;
int i;
// ,
// -
int min;
//
// i
int j;
// -,
int buf;
// -
int ;
//
printf(" ");
printf(" ( %i", SZ);
printf(" ) <Enter>\n");
printf("->");
for ( = 0; < SZ; ++)
scanf("%i", &[]);
printf("..");
for (i = 0; i < SZ-1; i++)
{
// ~
/ / a[i] -
min = i;
for (j == i+1; j < SZ; j++)
if (a[j] < a[min]) min = j;
// a [min] a[i]
Ik
buf = [i];
a[i] = a[min];
a[itiin] = buf;
//
//
//
for ( = 0 ; < SZ; ++)
printf ("%i ", ,[]);
printf("\");
}
//
printf(" \");
for ( = 0; < SZ; ++)
printf("%i ", []);
printf("\");
printf("\ <Enter>");
getch();
154
// ""
#include <stdio.h>
#include <conio.h>
#define SZ 5
void main()
{
int a[SZ];
int i;
//
dint ;
//
int buf;
printf(" \"\"\");
printf(" ( %i ", SZ);
printf(" ) <Enter>\n");
for ( = 0; < SZ; k+-f)
scanf("%i", &[]);
printf("...\");
129
130
/-^-^-
for
(
(i = 0; i < S Z - 1 ; i++)
for
(k = 0; < S Z - 1 ; k++)
155
//
#include <stdio.h>
#include <conio.h>
#define SZ 5 // 1
void main
{
int a[SZ], b[SZ]; //
int c[SZ*2];
// -
int k,i,m;
// a, b
printf(" " ) ;
printf(" \");
printf(" " ) ;
II.
printf("(%i ) -> ", SZ);
for ( = 0; < SZ; ++)
scanf("%i", &[]);
printf(" " ) ;
printf("(%i ) -> ", SZ);
for (i = 0 ; i < SZ; i++)
scanf("%i", &b[i]);
= i = m = 0;
do {
if (a[k] < b[i] )
c[m++] = a[k++];
else
if (a[k] > b[i])
c[m++] = b[i++];
else {
[++] = a[k++];
c[m++] = b[i++] ;
}
} while ( < SZ && i < SZ); //
//
while ( < SZ) // - ,
[++] = [++];
while (1 < SZ) // - ,
[++] = b[i++];
printf(" - : \ " ) ;
for (1 = 0; i < 2 * SZ; i++)
printf("%i ", c[i]);
printf(" <Enter>\n");
getch();
}
156
//
#include <stdio.h>
#include <conio.h>
131
132
C/C-t"i- it
#define SZ 10
//
void main()
{
int a[SZ]; //
int obr;
//
int ok;
// 1 -
int verh,niz;
// ,
//
int sred;
//
int found;
// 1 -
int ;
//
//
int i;
//
printf("***
");
printf(" * * * \ " ) ;
printf(" ( %i ", S Z ) ;
printf(" ) <Enter>\n");
printf("->
");
II.
133
157
//
#include <stdio.h>
#include <conio.h>
#define SZ 30
// -
void main
{
int r;
//
134
/-^"*-
int rost[SZ]; //
int = 0;
//
//
float sred;
//
int m = 0;
//
//
int sum = 0 ; //
int i == 0;
- ,
- ,
printf("*** ***\");
printf(" () ");
printf(" <Enter>\n");
do {
printf("-> " ) ;
scanf("%i", &r);
if ( r )
{
rost[i++] = r;
sum += r;
+-1-;
}
} while (r && i < SZ) ;
if ( n )
{
sred = (float) sum / n;
m = 0;
//
for (i = 0; i < n; i++)
if (rost[i] > sred) m++;
printf(" : %3.2f \", sred);
printf(" %i ", m) ;
}
printf("\ <Enter>");
getch();
II.
158
// ( )
#include <stdio.h>
#include <conio.h>
idefine ROW 3
// -
#define COL 5
// -
void mainO
{
int a[ROW][COL]; //
int s[COL];
//
int i,j;
printf("\ ");
printf(" ,");
printf("\n%i , <Enter>\n", COL);
for (i = 0; i < ROW; i-f+) // ROW
{
printf("->");
for (j = 0; j < COL; j++)
scanf("%i", &a[i][j]);
}
printf(" ");
for (i = 0; i < ROW; i++)
{
for (j = 0; j < COL; j++)
printf("%i " , a[i][j]);
printf("\n");
}
// "" s
for (i = 0; i < COL; i++)
s[i3 0;
//
for (j = 0 ; j < COL; j+-f-)
//
for (i = 0; i < ROW; i++) // -
s[j] += a[i3[j];
135
136
C/C++
printf ("
for (i = 0; i < COL; i++)
printf("%i ", s[i]);
\") ;
printf("\ <Enter>");
getch();
}
160
/ /
#include <stciio.h>
#include <conio.h>
void main()
{
int n[6];
// , ...,
int s = 0; //
float p[6]; //
char *mes[6] ={"\0", "\0", "","",
"",""};
int i;
puts(" ");
puts(" :");
for (i = 5; i >= 2; i)
{
printf("%s ->", mes[i]);
scanf("%i", &n[i]);
s += n[i];
}
//
for (i = 2; i < 6; i++)
p[i] = (float)n[i]/3*100;
puts(" ");
puts ("
") ;
for (i = 5; i >= 2; i)
printf("%8s %2i
%2.0f%\n",mes[i], n[i], p[i]);
puts ("
") ;
II.
/37
puts(" <Enter>");
getch();
}
162
//
tinclude <stdio.h>
tinclude <conio.h>
void mainO
{
float a[2][2];
//
float det;
//
int i,j;
//
()
printf(" .\n");
printf(" <Enter>\n");
for (i = 0; i < 2; i+4-)
{
printf("->");
scanf("%f%f",
&a[i][0],
&a[i][l]);
det);
printf("\ <Enter>");
getch();
}
163
//
#include <stdio.h>
#include <conio.h>
#define N 3 //
138
C/C-i'+
v o i d main ()
{
int m[N][N+1]; //
//
int max;
//
//
int i,j;
//
puts("\nOnpe ");
puts (" ") ;
printf(" %ix%i\n", N, N ) ;
for (i = 0; i < N; i++)
{
printf(" %i- -> ", i+1);
for (j = 0; j < N; j++)
scanf("%i", &m[i] [j]);
}
// -
for (i = 0; i < N; i++)
{
m[i][N] = 0;
for(j = 0; j < N; j++)
m[i][N] += m[i] [j];
}
//
max = 0;
for (i = 1 ; i < N; i++)
if ( m[i] [N] > m[max] [N] )
max = i;
printf("\nB %i- ", max+1);
printf(" %i\n", m[max][N]);
printf("\ <Enter>\n");
getch();
II.
164
// , ""
#include <stdio.h>
#include <conio.h>
#define SZ 5
//
void main
{
int a[SZ][SZ]; //
int n;
//
int ok;
// - ""
int i,j;
//
int sum;
// -
int temp;
// ,
//
printf ("*** 1 ***\") ;
printf("\ (3..%i) -> ", SZ);
scanf{"%i", &n);
printf(" ");
printf(" , %i , ", ) ;
printf(" <Enter>\n");
for (i = 0 ; i < n; i++)
{
printf("->");
for (j = 0; j < n; j++)
scanf("%i", &a[i][j]);
}
ok = 1; // - ""
//
sum = 0;
for (i = 0; i < n; i++)
sum += a[i][i];
//
i = 0;
do {
temp = 0 ; // -
for (j = 0; j < n; j++)
temp += a[i][j];
139
140
C/C-h-h
i f (temp != sum) ok = 0;
i++;
} w h i l e (ok && i < n ) ;
if
( ok )
//
//
//
j = 0;
do {
tertp = 0; // -
for (i = 0 ; i < n; i++)
temp += a[i][j];
if (temp != sum) ok = 0;
j++;
} while (ok && i < n ) ;
}
if ( ok ) {
//
//
// .
//
//
temp = 0;
1 - - 1;
for (j = 0; j < n; j++)
temp += a[i] [j] ;
if (temp != sum) ok = 0;
}
printf(" " ) ;
if ( !ok )
printf(" " ) ;
printf(" \"\".\n");
printf("\ <Enter>");
getch();
II.
165
//
#include <stdio.h>
#include <conio.h>
void main ()
{
char name[15]; //
char fam[20] ; //
printfC'KaK ?\") ;
printf(" ,");
printf(" <Enter>");
printf("-> " ) ;
scanf("%s", &name);
scanf("%s", &fam);
// scanf
// -
printf(", %s %s!\n", name, fam);
printf("\ <Enter>");
getch();
}
166
// ( )
#include <stdio.h>
#include <conio.h>
void main()
{
char name[40]; //
char cti;
int i;
printf(" ?\");
printf("( , <Enter>");
printf("-> " ) ;
i = 0;
while ( (cli=getch() ) != 13 && i < 40) //
// <Enter>
141
142
C/C+'t-
{
putch(ch);
name[i++] = ch;
naine[i] = 40;
printf(", %s!\n", );
printf("\ <Enter>");
getch();
}
167
//
#include <stdio.h>
#include <conio.h>
void mainO
{
dtiar St [80]; //
int i = 0;
//
puts(" <Enter>");
printf("->");
gets (st);
while( st[i++])
168
//
#include <stdio.h>
#include <conio.h>
#include "dos.h" // delay
void main
{
char msg[] = "\\ !\0";
int i;
//
//.
i = 0;
while(msg[i])
{
putch(msg[i++3);
delay(150);
}
printf("\\ <Enter>");
getch();
}
169
//
#include <stdio.h>
#include <conio.h>
void mainO
{
unsigned char ch;
// ch char,
//
printf(" .\");
printf(" .\");
do {
ch = getch();
printf(": %c : %i\n", ch, ch);
} while ( ch !- .');
printf("\\ <Enter>");
getch();
170
// ASCII-
#include <stdio.h>
#include <conio.h>
tdefine
SM 128 // 0 - - 127
// 128 - 128 - 256
143^
144
C/C-f-^-
void main
{
// ch char,
//
unsigned char ch;
//
int i,j;
printf ("- \") ;
for (i = 0; i <= 16; i++) //
{
ch = i + SM;
for (j = 1; j <== 8; j++) //
{
if (( ch <7 ch >= 14) && ch !=26)
printf("%3c -%4i", ch, ch);
else // CR, LF, TAB
printf("%3c ", ch, ch);
ch += 16;
}
printf("\n");
}
printf("\ <Enter>");
getch();
}
171
//
#include <stdio.h>
#include <conio.h>
void mainO
{
unsigned dtiar st[80]; //
int i;
//
printf(" <Enter>");
printf("->");
gets(st);
i = 0;
II.
145
while ( s t [ i ] )
{
printf("\n%s\n",
St);
printf("\ <Enter>");
getch();
}
172
//
#include <stdio.h>
#include <conio.h>
#include "string.h"
void mainO
{
lansigned char sst[80]; //
unsigned char dst[80]; //
int i,j;
printf(" ");
printf(" :");
i=0;
while ((sst[i] = getchO) != 13)
putch(sst[i++]);
sst[i] = '\0';
i = 0; j = 0;
// ,
while( sst[i] && sst[i] == ' )
i++;
// i - , ,
// sst dst
146
C/C-^-i-
while ( s s t [ i ] )
dst[j++] = sst[i++];
dst[j] = 'NO';
printf(" :%s\n",dst);
printf(" <Enter>")/
getch();
173
// ,
#include <stdio.h>
#include <conio.h>
void mainO
{
char St[40];
//
int i;
//
printf(" <Enter>");
printf("->");
scanf("%s",&st);
i = 0;
while (st[i] >= '0 && st[i] <- '9')
i++;
// st[i] *\0',
printf(" " ) ;
if (st[i])
printf(" " ) ;
printf(" . Xn"};
printf(" <Enter>");
getch();
}
175
// ,
//
II.
#include <stdio.h>
#include <conio.h>
#include "string.h"
void mainO
{
char St[20]; //
int i;
//
printf(" - > " ) ;
scanf("%s", &st);
strupr(st); //
i = 0;
while ((st[i] >- '* && st[i] <= '9') I I
(st[i] >= 'A' && st[i] <= 'F'))
i++;
printf(" " ) ;
// st[i] != '
// i -
if ( st[i] )
printf(" " ) ;
printf (" ");
printf(" <Enter>");
getch();
}
176
// ,
//
#include <stdio.h>
#include <conio.h>
void main()
{
char st[20];
//
int i;
//
int ok = 0;
//
147
14S
C/C-f"^
printf(" <Enter>");
printf("->");
scanf("%s", &st);
i = 0;
if
(st[i] >= '1' && st[i] <='9') //
{
/ /
whil# ( st[i] >- '1' && st[i]
<-'9' )
i++;
/ /
if (st[i]
'.')
{
i+--;
/ /
if
{
/ /
while ( st[i] >= '1' && st[i] <='9' )
i+-f;
ok = 1; // -
}
}
}
printf(" %s " , s t ) ;
if ( st[i] I I !ok )
printf(" " ) ;
printf (" " ) ;
printf("\ <Enter>");
getch();
}
177
//
tinclude <stdio.h>
#include <conio.h>
#include "string.h"
void m a i n O
{
IL
char bin[16];
long int dec;
int i;
int v;
149
//
//
//
//
i-
printf(" " ) ;
printf("H <Enter>");
printf("->");
scanf("%s", &bin);
dec = 0;
V = 1;
// (0-)
for ( i *= strlen(bin) -1; i >= 0; i)
{
if ( bin[i] = = ' ! ' )
dec += v;
V *= 2;
//
}
printf(" %s", bin);
printf(" %d", dec);
printf ("\ ^^^ <Enter>") ;
getch();
178
//
// !
#include <stdio.h>
#include <conio.h>
#include "string.h"
void mainO
{
char St[5];
//
unsigned int dec;//
int v;
//
int err = 0;
// err = 1 -
int i;
150
/+-1'
printf(" " ) ;
printf("( 4- ) \");
printf("-> " ) ;
scanf("%s",&st);
//
strupr(st);
dec = 0;
V = 1;
//
//
for ( i = strlen(st) -1; i >= 0; i)
{
//printf("\n%d\n",v);
if (st[i] >= '0' && st[i] <= '9M
dec +- V * (st[i]- 48); // (int)'0'=48, (int)l'=49
// ..
lee
if (st[i] >= 'A' && st[i] <= 'FM
// (int)'A'=65, (int)'B'=66 ..
// A 10, - 11 ..
dec += V * (st[i3- 55);
mlsm //
{ err = 1;
break; }
V *= 16;
//
}
if ( !err ) {
printf(" %s ", st);
printf(" %u\n", dec);
}
else {
printf (" %s ", st);
printf(" ");
}
printf("\ <Enter>");
getch();
II.
179
//
// ( 2- 10-)
#include <stdio.h>
#include <conio.h>
void mainO
{
int osn.
//
n,
//
,
//
;
//
// . .
char st[17]; //
//
int i;
printf(" ->");
scanf("%d", &n);
printf(" ->");
scanf("%d", &osn);
= n;
//
// ,
// .
// -
st[16] ='\0';
i = 15;
do {
= n % osn; //
= / osn; //
// printf(":%d :%d\n", r,n);
st[i] = + 48; // 1
} while ( > 0);
// ""
i++;
int j = 0;
while(St[i])
st[j+-f] = s t [ i + + ] ;
st[j] = 40';
151
152
/+-^
st[i] = ' ';
printf(" %d ", );
printf(" %s %d\n", st, osn);
printf("\ <Enter>");
getch();
180
//
#include <stdio.h>
#include <conio.h>
void main()
{
int n;
//
int r;
//
//
char st[5];
//
//
int i;
printf(" );
printf (." \") ;
printf(" ->");
scanf("%d", &);
// 16 ,
// 16
printf(" %d", ) ;
printf(" " ) ;
st[5] = 4 0 ' ;
i = 4;
do {
r=n%16;
//
n=n/16/
/ / -
i f ( < 10)
st[i] = + 48; / / (int) ' 0 ' = 4 8 , (int) 1==49 . .
e l s e s t [ i ~ ] = + 55; / / (int)''==65, (int)'==6
/ / . .
} while ( > 0) ;
II.
//
i++;
int j = 0;
while( st[i] )
st[j++] = st[i++];
st[j] = 4 0 ' ;
printf("%s\n", St);
printf("\ <Enter>");
getch();
}
181
//
iinclude <stdio.h>
#include <conio.h>
#include "stdlib.h"
void main ()
{
char St[40]; //
char buf[10]; //
char op;
//
int rez;
//
int n;
//
int i,j;
printf(" ,\n");
printf(", 45+5-3-125+2 <Enter>");
printf("( )\");
printf("->");
scanf("%s", &st);
rez == 0; //
op = ' ;
i = j = 0;
while( st[i] )
{
//
153
154
/+-^-
j = 0;
while (st[i] >= '' && st[i] <= '9
buf[j++] = st[i++];
buf[j] = 40\n = atoi(buf); //
//
switch ( op )
{
case ' + ': rez += n; breadt;
case '-': rez ~= n; breakscase ' ': rez = n; break; //
}
//
= St [i++];
}
printf(" : %d", rez);
printf("\ <Enter>");
getch();
}
182
// 2000
#include "stdio.h"
#include "conio.h"
#include "string.h"
#define NC 10
// -
void main()
{
char *strana[] = {"\0","",
"", "\0", "3\0",
"","",
"","",""};
//
int result[NC+1][5];
// NC+1-
//
IL
155
int i,j;
int max;
// ,
//
char buf[9]; //
printf("\*** 2000 ***\");
printf(" ,\");
printf(" ");
//
for (i = 0; i < NC; i4-+)
{
printf("%s ->", strana[i]);
scanf("%i%i%i", ^result[i][0],
Sresult [i] [1],
&result[i][2]);
}
//
// 1
//
//
for (i = 0; i < NC; i++)
{
result[i] [3] =
result[i][0]+result[i][l]+result[i][2];
result[i] [4] =
result[i][0]*7+result[i][1]*6+result[i][2]*5;
}
//
//
for (i = 0; i < NC-1; i++)
{
/ / , i,
// j- ,
// result [j] [5]
max = i; // i
for (j = i+1; j < NC; j+-b)
if (result[j][4] > result[max][4]) max = j;
// 1~ max
/ /
// .
156
/+-^
strcpy(buf,strana[i]);
strcpy(strana[i],strana[max]);
strcpy(strana[max],buf);
for (j = 0; j < 5; j++)
result[NC][j] = r e s u l t [ i ] [ j ] ;
f o r (j = 0; j < 5; j++)
r e s u l t [ i ] [ j ] = result[max][j];
f o r (j = 0; j < 5; j4-+)
result[max][j] = result[NC][j];
}
//
printf(" , 2000 .\");
printf("%12s%8s%8s%8s%8s%8s","","",
"","","","");
for (i = 0; i < NC; i++)
{
printf("\n%12s", strana[i]);
for (j = 0; j < 5; j+4-)
printf("%8i", result[i][j]);
}
printf("\ <Enter>");
getcli () ;
}
183
// " "
#include "stdio.h"
#include "conio.li"
#include "stdlib.li"
#include "time.li"
#define N 3
#define DEBUG
// -
//
void main()
{
char igro]c[N];
char comp[N];
//
//
II.
int a[N];
157
// a[i] == 1, i-
//
int ugad;
int mesto;
//
//
int i,j;
time__t t;
//
158
C/C++
a[j] = 1; //
// ,
// ,
break;
}
}
// ,
mesto = 0;
for (i = 0; i < N; i++)
if (igrok[i] == comp[i]) inesto++;
printf(": %i. Ha : %i", \
ugad, mesto);
} while ((ugad < N) || (mesto < N));
printf("\n*** ! ***\n");
printf("\ <Enter>");
getch();
}
184
// -
#include "stdio.h"
#include "conio.h"
#include "string.h" // strlen
#include "dos.h"
// delay
//
#define TONE 100 // ()
#define
LI
50 // () ""
#define
L2 100 // () ""
#define
L3
50 // ()
//
#define
L4 100 // ()
#define
L5 150 // ()
void main
{
//
char *morse[] = {
I
__
if_
II
II
II
II
II
/ /7\
159
II.
fl
tl
II
_^11
_"
'_ "
II
II
II
// ,,,3
// ,,,
II /// ,,,
II
// ,,,
II
II
II
II
II
II
II
"
II
II
II
II
|__
II
II
II
II
II
_||
|_
II
II
II
__
__
II
^11
II
II
_ 1 |
//
,,,
/ // ,,,
// ,,,
};
lansigned char mes[80]; //
char sim[4];
// //
char znak;
// "" -
int i,j;
//
puts("\n*** * * * " ) ;
puts(" , ");
puts("( )");
printf("->");
gets(mes);
f o r ( i = 0; i < s t r l e n ( m e s ) ; i++)
{
if
/ / > (- Ord)
/ /
/ / -
strcpy(Sim, morse[mes[i]-128]);
j = 0;
do
i f ( s i m [ j ] == ' - ' 11 s i m [ j ] == ' . ' )
{
putch(sim[j++]);
sound(1000);
if (sim[j] == '.M
delay(LI);
else delay(L2);
nosound;
delay(L3);
}
160
C/C++
while ( sim[j] ! = ' & & j <4 ) ;
delay(L4); //
}
else
if (mes[i] == ' ) //
{
printf(" " ) ; //
delay(L5);
}
}
puts(" !");
puts(" <Enter>");
getch();
}
185
#include <stdio.h>
#include <conio.h>
#include <math.h> // M_PI
//
float veil(float h, float r)
{
return(M_PI*r*r*h);
}
void mainO
{
float r,h; //
float v;
//
puts(" ");
printf(" ->");
scanf("%f%f", &h, &r)/
V = veil (h, r) ;
printf(" %3.2f\n", v ) ;
printf(" <Enter>");
getch();
}
II.
161
186
// max
int max(int , int b)
{
if (a > b)
return(a);
else
return (b) ;
}
187
// compare
/ /
tinclude "stdio.h"
#include "conio.h"
//
//
puts(" <Enter>");
printf("->");
scanf("%i%i", &xl, &x2);
res = compare(xl,x2); //
printf("%i %c %i\n", xl, res, x2);
puts("\n \
<Enter>");
getch();
162
/-^+
188
//
float sopr( float rl, float 2, int t)
(
// rl,r2 -
// t - :
//
1 - ;
//
2 - .
// ,
// -1
f l o a t ;
i f ( t==l) = rl + 2;
e l s e i f (t== 2) = 1*2/(1+2);
else = -1;
return();
}
191
// ""
#include "stdio.h"
#include "conio.h"
unsigned int factor(int x)
{
unsigned int f = 1;
for (int i = 2; i <= x; i++)
f *= i;
return(f);
}
void main()
{
unsigned int f;
puts(" ");
for (int n = 1; n <= 8; n++)
{
f = factor(n);
printf("%2i %u\n", n, f);
}
11.
163
puts("\n <Enter>");
getch();
}
192
//
float dohod(float sum,
//
float stavka, // ()
int srok)
// ()
{
return(sum*(stavka/100/365)*srok); // 365 -
/ /
}
193
// ,
int glasn(char ch)
{
static char gl[] ="\0";
int i = 0;
while (gl[i] && gl[i] != ch)
i++;
if ( gl[i] )
return(1);
else return(0);
195
// upcase
#include "stdio.h"
#include "conio.h"
//
char* upcase (chau: *st)
{
int i = 0;
while ( st[i] )
164
C/C-i-f-
{
196
//
#include "stdio.h"
tinclude "conio.h"
#include "math.h"
int kvadur(float a, float b, float c, // -
float *xl, float *x2)
//
// -
// -1,
{
float d; //
11.
if ( == 0) retum(-l);
d = b*b-4*a*c;
if (d < 0)
return(0);
//
*1 = (-b+sqrt(d))/(2*);
*2 = (-b-sqrt(d))/(2*a);
//
void main
{
float a,b,; //
float 1,2; //
int ;
// -
puts("\ ");
puts(" \
<Enter>");
printf("->");
scanf("%f%f%f", &a, &b, &c);
switch (kvadur(a,b,c,&xl, &x2))
{
case -1: puts(" .");
break;
case 0: puts(" .");
break;
case 1: printf(" : x=%3.2f", xl);
breaJc;
case 2:
}
puts("\n <Enter>");
getch();
165^
166
C/C+'f-
197
// starline
#include "stdio.h"
#include "conio.h"
//
void starline{int len)
{
for (int i = 0; i < len; i++)
putch('* M ;
}
void main()
(
starline(10);
puts("\n <Enter>");
getch();
}
200
// frame
#include "stdio.h"
#include "conio.h"
//
void frame(int 1, int t, int w, int h)
{
// l,t - ,
// vif h -
int ,; //
int i;
// ,
char 1 == 218, //
2 = 196, //
= 191, //
4 = 179, //
5 = 192, //
- 217; //
II.
167
gotoxy(l,t);
putch(cl);
for (i = 0; i < w-2; i++) //
//
putch(2);
putch(c3);
= t+1;
X = 1+w-l;
for (i = 0; i < h-1; i++) //
{
gotoxy(l,y);
putch(4);
gotoxy(,);
putch(4);
++;
}
gotoxy(1,);
putch(5);
for (i = 0; i < w-2; i++) //
putch(c2);
putch(c6);
}
void main ()
{
clrscr();
frame(5,5,30,10);
puts("\n <Enter>");
getch();
}
201
// getint
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
// getint
// , .
// , ,
// <Backspace>.
168
C/C-i'+
// <Enter>
// .
#define _ 8
// <Backspace>
#define K_ENTER 13 // <Enter>
#define
4
//
int getint()
{
char ch;
//
char buf[HB]; //
int n = 0;
// -
buf[0] = 40;
w h i l e ((ch = g e t c h O ) != K_ENTER)
i f (ch >= ' 0 ' && ch <= '^^; n < HB)
{
putch(ch);
buf[n++] = ch;
}
e l s e i f (ch == K_BACK && n)
{
printf("\b \b");
n;
}
i f (n)
{
buf[n] = '\0';
return(atoi(buf));
}
else retum(-l);
void main () {
int a; //
puts(" getintXn");
puts(" getint ");
puts(" .");
puts(" , , ");
puts(" <Backspace>");
II.
puts(" <Enter> ");
puts(" -1, .");
puts(" <Enter>");
print("->");
if ( = getintO )
printf("\nBbi %d", ) ;
else puts(" .");
puts("\n <Enter>");
getch();
}
202
// getfloat pos
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
int pos(char* st, char c)
{
int i = 0;
while ( st[i] != && st[i] )
i++;
if ( st[i] )
return(i+1);
else
return(0);
}
//
float getfloat
{
#define N 10 // - ,
char ch;
char buf[N+1];
int i;
169
0/0+-^
170
if ( !(pos(buf,'.')))
{
putch(ch);
buf[i++] = ch;
}
break;
if (i)
printf("\b \b");
buf[i] = 40;
}
} while (ch != 13)<
return(atof(buf));
}
void main (void)
{
float f;
printf(" - > " ) ;
f = getfloatO ;
printf(" %e\n", f);
getch();
11.
171
203
// "21"
#include "stdio.h"
tinclude "conio.h"
#include "stdlib.h" // rand
iinclude "time.h"
// time
int koloda[12];
int kartaO;
void main ()
{
int igrok = 0 ;
int comp = 0 ;
char otv;
time_t t;
//
// ""
//
//
//
//
for (int i=2; i <=11; i++)
koloda[i] = 4;
koloda[5] = 0 ; // ""
//
srand((unsigned)time(&t))/
printf("\ !\");
do {
//
igrok += karta();
//
if (igrok < 21)
comp += karta();
if (igrok < 21 && comp < 21)
{
printf(" %d\n",igrok);
printf(" ? ( ) " ) ;
otv = getchar();
172
C/C-i-'i'
// : <Enter>
// getchar .
//
// <Enter>. .
int b;
b = getchar();
}
} while (igrok <= 21 && comp <= 21 && otv != 'nM ;
if (igrok = = 2 1 || (igrok < 21 && igrok > comp)
I I comp > 21)
printf("B !\n");
else
printf(" !\n");
printf (" %d\n", igrok);
printf (" %d\n", comp);
printf(" <Enter>");
getch();
}
//
int karta()
{
int i;
do
i = randO % 10 +2;
while (koloda[i] == 0);
koloda[i];
return i ;
205
/ /
#include <graphics.h>
#include < s t d l i b . h >
t i n c l u d e <stdio.h>
#include <conio.h>
IL
173
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
exit(l);
}
// -
setfillstyle(SOLID_FILL,LIGHTGRAY); //
bar(80,80,200,135);
//
setcolor(GREEN);
circle(100,100,15);
setcolor (BLACK");
circle(140,100,15);
setcolor(RED);
circle(180,100,15);
setcolor(YELLOW);
circle(120,115,15);
setcolor(BLUE);
circle(160,115,15);
//
//
//
//
//
getch();
closegraph0; //
174
C/C++
208
// ( )
#include <graphics.h>
tinclude <stdlib.h>
iinclude <stdio.h>
tinclude <conio.h>
#define dx
#define dy
10
10
// X
// Y
II.
209
//
//
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
tinclude "time.h"
#include "dos.h"
tdefine PATHTODRIVER "c: WborlandcWbgiW"
//
void cuzor(int n)
{
175
176
C/C-t"^
#define DELAY
int
K,y,r;,
//
//
time t t;
srand((unsigned)time (&t)); //
for (int i = 0; i < n; i++)
{
X = randO % 640
= randO % 480
r = randO % 240
setcolor (randO %16)
circle(x,y^ r)f
#ifdef DELAY
delay(5);
#endif
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
exit(l);
cuzor(200); //
getch();
closegraph(); //
11.
177
211
//
//
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include "time.h"
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void luzor(int n)
{
int x,y;
//
int ;
//
time_t t;
srand((unsigned)time(&t)); //
for (int i = 0; i < n; i+4-)
{
X = randO % 640;
= randO % 480;
= randO % 16;
setcolor(c);
lineto(x,y);
}
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode J= grOk)
//
//
178
C/C-^-f-
{
212
//
#include <graphics.h>
tinclude <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
#include "math.h"
void starline(int xO, int yO, int r)
{
// xO, yO -
/ / -
int ,;//
//
int ; //
//
//
int rl; //
//
II.
179
= 18;
// .
1 = r/RTOR;
X = xO+r*cos(a*2*M_PI/360);
= yO-r*sin(a*2*M_PI/360);
moveto(x,y);
for (int i = 0; i < 5; i++)
{
a = a+36;
X = xO+rl*cos(a*2*M_PI/360);
= yO-rl*sin(a*2*M_PI/360);
lineto(x,y); //
= +36;
if ( > 360) = 18;
X = xO+r*cos(a*2*M_PI/360);
= yO-r*sin(a*2*M_PI/360);
lineto(x,y); //
}
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &ginode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
exit(l);
}
s t a r l i n e d O O , 100, 50);
getch();
closegraph0; //
180
C/C-^-i-
213
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
#include "math.h"
void star(int xO, int yO, int r)
{
// xO, yO -
/ / -
int poly[20]; //
/ /
int ; // ,
//
//
int rl; //
//
#define RTOR 2.5 //
/ /
int i;
= 18;
// .
rl = r/RTOR;
i=0;
do {
poly[i++] = xO+r*cos(a*2*M_PI/360);
poly[i++] = yO-r*sin(a*2*M_PI/360);
a = a+36;
poly[i++] == xOH-rl*cos(a*2*M_PI/360) ;
poly[i++] = yO~rl*sin(a*2*M_PI/360);
a = a+36;
if (a > 360) a = 18;
} while(i < 20);
setfillstyle(SOLID_FILL,RED);
II.
W1^
fillpoly(10,poly);
}
v o i d main (void)
{
//
//
{
printf(": %d\n", errorcode);
puts (" ! <Enter>");
getch();
}
else {
star(100, 100, 20);
getch();
closegraph0; //
}
}
215
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
void rusflag(int x, int y, int 1, int h)
{
// X, -
// 1, h -
int W = h / 3;
//
setfillstyle(SOLID_FILL,WHITE);
182
C/C-f-f-
bar(,,+1fy+w);
setfillstyle(SOLID_FILL,BLUE);
bar(x,y+w,x+l,y+2*w);
setfillstyle{SOLID_FILL,RED);
bar(x,y+2*w,x+l,y+3*w);
outtextxy(x,y+h+5,"");
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
return;
}
rusflag(100,100,50,25);
getch();
closegraph(); //
216
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
II.
183
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
return;
}
face (100,100);
getch();
closegraphO; //
219
//
#include <graphics.h>
tinclude <stdio.h>
#include <conio.h>
184
C/C'^-'^'
int X = 100,
= 100;
int = 5;
int dr = 5;
int color;
//
//
//
//
220
//
#include <graphics.h>
II.
185
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void uzor()
{
int X = 100,
//
= 100;
int = 20;
//
int d = 30;
//
int i,j;
//
for (1 = 0; 1 < 4; i++)
{
X = 100;
for (j = 0; j < 5; j++)
{
circle(x, y, r);
X += d;
}
+= d;
}
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
186
/-*"*-
return;
}
uzor();
getch();
closegraph; //
}
221
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void uzor()
{
int x;
int = 100;
int n;
//
int d = 30;
//
int 1 = 10;
//
for (int i = 0; i < 5; i++)
{
// X
if (i % 2)
{ //
= 5;
//
X = 100;
}
else { //
= 4;
X = 100 + d/2+1/2;
}
for (int j = 0; j < n; j++)
{
rectangle(x,y,x+d,y+d);
X += d+1;
}
If.
187^
+= d/2+1/2;
}
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, Sgitiode, PATHTODRIVER) ;
errorcode = graphresult();
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" ^ <Enter>");
getch();
return;
}
uzor();
getch();
closegraph0; //
222
//
#include <graphics.h>
tinclude <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void doska()
{
int xO = 100,
//
= 100;
188
C/C++
int ,;
int W = 25;
int i,j;
//
//
//
X = ;
= ;
for (1 = 0; i < 8; i++)
//
{
for ( j = 0; j < 8; j++) //
{
//
// ,
// , , - ,
//
-
if ((i+j) % 2)
setfillstyle(SOLID_FILL,BROWN);
else setfillstyle(SOLID_FILL,YELLOW);
bar(x,y,x+w,y+w);
X += w;
}
X = xO;
+= w;
}
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
II.
return;
doska ;
getch();
closegraph; //
223
/ /
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
int flagO
{
int point[12]; //
//
point[] = 100; point[1] = 100;
point[2] = 160; point[3] = 100;
point[4] = 140; point[5] = 120;
point[6] = 160; point[7] = 140;
point[8] = 100; point[9] = 140;
point[10]= 100; point[11] = 100;
setfillstyle(SOLID__FILL, RED);
fillpoly(6, point);
line(100, 140, 100, 170);
189
190
C/C'^^'^
if (errorcode != grOk)
//
//
{
intf(": %d\n", errorcode);
puts(" <Enter>");
getch();
return;
}
flag ;
getch();
closegraph(); //
224
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void parovoz(int xO, int yO)
{
#define dx 5 //
#define dy 5 //
int tr[30]; //
/ /
tr[0]
tr[2]
tr[4]
tr[6]
tr[8]
tr[10]
tr[12]
tr[14]
=
=
=
=
=
=
=
=
xO+0*dx
xO+0*dx,
xO+l*dx
xO+l*dx,
x0+2*dx,
x0+2*dx,
x0+3*dx,
x0+3*dx,
tr[l]
tr[3]
tr[5]
tr[7]
tr[9]
tr[ll]
tr[13]
tr[15]
=
=
=
=
=
=
=
=
y0+7*dy;
yO+6*dy;
yO+6*dy;
y0+3*dy;
y0+3*dy;
yO+0*dy;
yO+0*dy;
y0-f3*dy;
191
II.
tr[16] = x0+7*dx;
tr[18] = x0+7*dx;
tr[20] = x0+13*dx
tr[22] = x0+13*dx
tr[24] = x0+12*dx
tr[26] = x04-12*dx
tr[28] = x04-0*dx;
drawpoly(15,tr);
tr[17]
tr[19]
tr[21]
tr[23]
tr[25]
tr[27]
tr(29]
= y0+3*dy;
== yO+l*dy;
= yO+l*dy;
= y0+2*dy;
= y0+2*dy;
= y0+7*dy;
== y0+7*dy;
//
rectangle(x0+8*dx,y0+2*dy,xO+10*dx,yO+4 *dy)<
//
setf illstyle(SOLID__FILL, RED) ;
setcolor(RED);
pieslice(x0+3*dx,y0+7*dy,0,360,l*dx),
pieslice(xO+6*dx,y0+7*dy,0,360,l*dx)^
pieslice(x0+9*dx,y0+7*dy,0,360,l*dx)<
//
setcolor(WHITE);
circle(x0+3*dx,y0+7*dy,l*dx),
circle(x0+6*dx,y0+7*dy,l*dx) ,
circle(x0+9*dx,y0+7*dy,l*dx) ,
192
C/C++
p u t s ( " < E n t e r > " ) ;
getch();
}
226
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
void gridO
{
int xO,yO; //
int dx,dy; // ( )
int h,w;
//
//
int ,;
float 1,1;
float dlx,dly;
char St [8];
// X Y
// X Y
//
/ /
Iine(x0,y0,x0,y0-h); // X
Iine(x0,y0,x0+w,y0); // Y
// , X
II,
X = ;
do {
/ /
setlinestyle(SOLID_LINE, , 1);
line(,0-3,,0+3);
//
sprintf (St, "%2. If ) ;
outtextxy{x-8,y0+5,st);
Ix += dlx;
//
setlinestyle(DOTTED_LINE, , 1) ;
line(x,yO-3,X,yO-h);
X += dx;
} while (x < xO+w);
// , Y
= ;
do {
//
setlinestyle(SOLID_LINE, , 1);
Iine(x0-3,y,x0+3,y);
//
sprintf(St,"%2.If",1);
outtextxy(-40,,st);
1 += dly;
//
setlinestyle(DOTTED_LINE, , 1);
line(x0+3,y,x0+w,y);
setlinestyle(SOLID_LINE, 0, 1);
-= dy;
} while (y > yO-h);
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
193^
194
C/C++
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
return;
}
grid();
getch();
closegraph0; //
227
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
void grafikO
{
float x,dx;
float 1,2;
float ;
int mx,my;
int ,;
int ,;
//
//
//
// X Y - -
// ,
//
//
//
= 320; = 240;
= 20; = 20;
//
Iine(10,y0,630,y0);
IL
W5^
Iine(x0,10,x0,470);
//
xl = -15;
x2 = 5;
dx = 0.1;
X = xl;
while ( X < x2 )
{
= 0.5*x*x + x*4 - 3;
px = xO + x*inx;
py = yO - y*my;
putpixel(px,py,WHITE);
X += dx;
}
// -
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>"),
getch();
return;
grafikO ;
getch();
closegraph0; //
}
196
C/C-f-f-
228
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
// delay
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void okr(int x, int y, //
int r,
//
int color)
//
{
setcolor(color);
circle(x,y,r);
}
int x,y;
//
int = 5; //
#define dt 10
#define dx 5
int maxx;
//
// 0.01
//
// X
//
II.
X = 0;
/ /
= 100;
= getmaxx();
while ( < )
{
(,,r,RED); //
delay(dt);
//
okr(,,,BLACK)///
X += dx;
}
closegraphO; //
}
else
{
intf(": %d\n", errorcode);
puts(" <Enter>");
getch();
}
229
//
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define dx
#define dy
5
5
// X
// Y
197
198
/+-^
lineto(x+14*dx^ ) ;
lineto(x,y);
//
moveto(x+3*dx,y-2*dy);
lineto(x+4*dx,y-3*dy);
lineto(x+4*dx,y-4*dy);
lineto(x+13*dx,y-4*dy);
lineto(x+13*dx,y-3*dy);
line(x+5*dx,y-3*dy,x+9*dx,y-3*dy);
//
rectangle(x+8*dx,y~4*dy,x+ll*dx,y-5*dy);
//
rectangle(x+7*dx,y-4*dy,x+8*dx,y-7*dy);
//
circle(x+12*dx,y-2*dy,dx/2);
circle(x+14*dx,y-2*dy,dx/2);
//
line(x+10*dx,y-5*dy,x+10*dx,y-10*dy);
//
moveto(x+17*dx,y-3*dy);
lineto(x+10*dx,y-10*dy);
lineto(x,y-2*dy);
//
//
II.
{
maxx = getmaxx();
X = -10 ; // -
// :,!
= 100;
while ( X < maxx)
{
ship(,, GREEN); //
delay(20);
ship(,,BLACK);
//
X += 5;
}
setcolor(GREEN);
outtext(10,10," !");
outtextxy(10,24," <Enter>");
getch();
closegraph; //
230
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
// 1
char *ines[] ={"\0", "\0",
"\0","\0"};
int n[4];
// , ,
//
199
200
/-^-+
float [4]; //
int h[4];
//
void obr() //
{
int s;
//
int m;
// -
int i;
//
puts(" ");
puts(" :");
for (i = 3; i >= 0; i)
(
printf("%s ->", mes[i]);
scanf("%i", &n[i]);
}
//
s = 0;
//
for (i = 0 ; i < 4; i++)
s += n[i];
//
for (i = 0; i < 4; i+-f)
p[i] = (float)n[i]/s*100;
// ,
// ,
m = 3; //
for (1 = 2; i >= 0; i)
if (n[i] > n[m]) m = i;
// , ,
// 200 .
// .
for (1 = 0 ; 1 < 4; i++)
h[i] = 200 * n[i]/n[m];
II.
void diagr()
{
int x,y; //
//
int 1;
//
//
int color[4] = {YELLOW, BLUE, GREEN, RED};
char buf[10];
outtextxy(40,50," \0");
rectangle(40,80,170,310);
X = 50; = 300; //
//
for (i = 3; i >= 0; i)
{
setfillstyle(SOLID_FILL, color[i]);
bar(x,y,x+10,y-h[i]); //
sprintf(buf,"%2.If",p[i]);
outtextxy(x,y-h[i]-10,buf);
X += 20;
}
//
X = 50;
for (i = 3; 1 >= 0; i)
{
setfillstyle(SOLID_FILL,color[i]);
//bar(x,y,x+10,y-h[i]); //
//OutTextXY(x,y-h[i]-10,RealToStr(p[i],5,l)+%\n");
X = x+20;
}
//
X = 200;y = 100;
for (i = 3; i >= 0; i)
{
setfillstyle(SOLID_FILL,color[i]);
bar(x,y,x+20,y+10); //
outtextxy(x+25,,mes[i]);
+= 20;
}
201
202
/-^"*-
void main
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
obrO; //
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode == grOk)
diagrO; //
else
{
printf(": %d\n", errorcode);
puts(" <Enter>");
}
getch();
}
231
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
#define N 4 //
void krdiagr(char*
{
int al,a2;
int color[4] =
int x,y;
char St[25];
int i;
II.
//
a l = 0;
/ /
X = 350; = 100; //
for (i = 0 ; i < N; i++)
{
//
a2 = al + 3.6 * dol[i]; // 1% - 3.6
if (i == N-1) a2 = 360; // , no ,
setfillstyle(SOLID_FILL, color[i]);
sector(200,200,al,a2,100,100);
// pieslice(200,200,al,a2,100);
al = a2; // -
//
(,,+30,+10);
rectangle(,,+30,+10);
sprintf(st, "%s - %2.1f%\0", name[i], dol[i]);
outtextxy(x+50,y,st);
+== 20;
}
}
void main (void)
{
char *name[N] = {"\0","\0",
"\0","\0"};
float kol[N]; //
float dol[N]; //
float sum = 0 ; // -
int i;
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
//
puts(" ");
for (1 = 0; i < N; i+-f)
{
printf("%s -> ", name[i3);
scanf("%f", &kol[i]);
203
204
C/C++
sum += kol[i];
}
//
for (i = 0; i < N; i+4-)
dol[i] = kol[i]/sum*100;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode == grOk)
{
krdiagr(name, dol);//
getch();
closegraphO; //
}
else {
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
}
232
//
#include <graphics.h>
#include <stdio.h>
#include <coniQ.h>
#include <dos.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void krug(int x,int , int r, int fc, int be)
{
// x, y, r -
// fc, be -
setfillstyle(SOLID_FILL,f);
setcolor(fc);
II.
205
pieslice(,,,360,);
setcolor(be);
circle(,,);
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode != grOk)
//
//
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
}
outtextxy(10,10," !");
rectangle(88,88,112,152);
//
krug(100,100,10,RED,WHITE);
krug(100,120,10,LIGHTGRAY,WHITE);
krug(100,140,10,LIGHTGRAY,WHITE);
for (int i = 1; i <= 3; i++)
{
//
delay(3000); // 3
krugdOO,120,10,YELLOW,WHITE) ; //
delay(1000);
krug(100,100,10,LIGHTGRAY,WHITE); //
krug(100,120,10,LIGHTGRAY,WHITE); //
krug(100,140,10,GREEN,WHITE);
//
delay(2000);
//
for (int j = 1; j <= 5; j++) // 5
206
C/C-i-'f-
{
delay(500);
krug (100 4 0 , GREEN, WHITE) ;
//
//
delay(500);
krug(100,140,10,LIGHTGRAY,WHITE);//
//
}
krug(100,120,10,YELLOW,WHITE);
delaydSOO);
krug(100,120,10,LIGHTGRAY,WHITE);
krug(100,100,10,RED,WHITE);
//
//
//
//
//
//
}
outtextxy(10,25," <Enter>!");
getch();
closegraph(); //
}
233
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <inath.h>
#include <dos.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
//
void vector(int ,
//
int 1)
//
{
#define G 0.0174532 // .
int ,; //
int 1,1; //
II.
207
= getx();
= gety();
1 = + l*cos(a*G);
1 = - l*sin(a*G);
lineto(xl,yl);
}
void clock
{
int xO = 80,
= 80;
int d = 50;
int s = 0;
int m = 0;
int as = 90;
int am = 90;
//
//
//
//
//
//
, -
, -
circle(,,d+5);
setfillstyle(SOLID_FILL, 0);
do {
//
moveto(xO,yO);
setcolor(YELLOW);
vector(as,d);
//
moveto(xO,yO);
setcolor(GREEN);
vector(am,d-10);
delay(lOOO); //
//
setcolor(0);
//
moveto(xO,yO);
vector(as, d);
//
moveto(xO,yO);
vector(am,d-10);
S++;
208
C/C-f"^
if (s > 60) {
m++;
s = 0;
am -== 6; //
if (am < 0) am = 354;
}
as -= 6;
if (as < 0) as = 354;
} while ( ikbhitO
}
void main (void)
{
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode - graphresult();
if (errorcode == grOk)
{
clock();
closegraph0; //
}
else
{
printf(": %d\n", errorcode);
puts(" <Enter>");
getch();
}
)
234
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
II.
209_
void grafik()
{
float xl=0,
//
2=25;
float 1,2; //
float ;
//
float ;
//
float dx=0.01;
int 1=50,
//
=400;
int w=300,
//
h=200;
float mx,my; //
int ,;
//
char St[25]; //
//
X Y
-
//
// [1,2]
1 = fl(xl); //
2 = fl(xl); //
X = 1 + dx;
do {
= fl(x);
if ( < yl) yl = ;
if ( > 2) 2 = ;
X += dx;
} while ( <= 2);
//
//
= h/fabs(2-1);
= w/fabs(2-1);
210
C/C-^-i'
= 1;
= b-abs(yl*my);
line(l,b,l,b-h);
Iine(x0,y0,x0+w,yO);
//
sprintf (St, "%3.2f',2) ;
outtextxy(l+5,b-h,St);
sprintf(St,"%3.2f",yl);
outtextxy(l+5,b,st);
//
X = xl;
do {
= f 1 (X) ;
putpixel (xO+x*inx, yO-y*my, 15);
X += dx;
} while (x <= x2);
II.
235
//
tinclude "stdio.h"
#include "conio.h"
#define FNAME "a:\\nuinbers.txt\0" //
#define N 5
//
// :
// ,
void main()
{
char fname[20] = FNAME;
FILE *out; //
int n;
//
puts(" ");
printf(" ");
printf("%s\n", fname);
puts(" <Enter>\n");
//
//
//
//
//
if
{
(w) (t)
1 ,
()
((out = fopen(fname, "wt")) == NULL)
printf(" ");
getch();
ret\2m;
}
for (int i = 0; i < N; i++)
{
printf("->");
scanf("%i", &n);
fprintf(out,"%i",n) ;
}
fclose(out);
//
211
212
C/C-f-t-
printf(" %s\n", fname);
puts("\nJUTR <Enter>");
getch();
236
//
#include "stdio.h"
#include "conio.h"
tdefine FNAME "a: Wnuinbers. txt\0" //
#define N 5
//
// :
// ,
void main()
{
char fname [20] = FNAiyiE;
FILE *out; //
int n;
//
puts(" ");
printf(" ");
printf("%s\n", fname);
puts(" <Enter>\n");
// () (t)
// ,
if ((out = fopen(fname, "at")) == NULL)
{
printf(" ");
getch();
return;
}
for (int i = 0; i < N; i++)
{
printf("->");
scanf("%i", &n);
fprintf(out,"%i\n",n);
II.
fclose(out);
//
printf(" %s\n", fname);
puts("\nXlnH <Enter>");
getch();
}
237
//
#include "stdio.h"
#include "conio.h"
#define FNAME "a: \\nuinbers.txt\0" //
void mainO
{
char fname[20] = FNAME;
FILE *in;
//
St [80]; //
printf(" %s\n", fname);
puts ("
") ;
// () (t)
if ((in = fopen(fname, "rt")) == NULL)
{
printf(" ");
getch();
retiim;
}
while (!feof(in))
{
fscanf(in,"%s", &st);
printf("%s\n", st);
}
fclose(in);
//
puts ("
");
puts("\n <Enter>");
getch();
213
214
/->'+
238
// ,
//
#include "stdio.h"
#include "conio.h"
#define FNAME "a:\\numbers.txt\0" //
void mainO
{
char fname[20] = FNAME;
FILE *in;
//
int a;
int n - 0;
int sum = 0 ;
float sr;
//
//
//
//
puts("\ ");
printf(", %s", fname);
// () (t)
if {(in = fopen(fname, "rt")) == NULL)
{
printf(" ");
getch();
return;
}
while (!feof(in))
{
fscanf(in,"%i", &a);
sum += a;
n++;
}
fclose(in);
//
sr = (float) sum / n;
printf(" : %i\n", n ) ;
printf(" 4Vic^Ji: %i\n", sum);
printf(" : %3.2f", sr);
215
239
// ,
//
#include "stdio.h"
#include "conio.h"
#include "string.h"
#define MAXLEN 80
void main()
{
char fname[40];
FILE *in;
//
//
//
char St[MAXLEN+2];// ,
int n = 0;
// - ,
char key;
// ,
puts(" ");
puts(" <Enter>");
intf("->");
scanf("%s",&fname);
// ' () (t)
if ((in = fopen(fname, "rt")) == NULL)
{
printf(" %s\n", fname);
getch();
return;
clrscr0;
while (!feof(in))
{
fgets(st, MAXLEN, in);
printf("%s", St);
if (++n > 21)
216
/-^-^
{
printf("\ ");
printf(" ...");
key = getch();
gotoxy(1,wherey()); //
//
delline;
// "
// ..."
= 0;
}
}
fclose(in);
//
printf("\ <Enter>");
getch();
}
240
// ,
tinclude "stdio.h"
#include "conio.h"
#define FNAME "a:Wphone.txt\0" //
void main()
{
char fname[20] = FNAME;
FILE *out; //
char fam[15]; //
char name[15]; //
char tel[9];
//
puts(" ");
// () (t)
// ,
if ((out = fopen(fname, "at")) == NULL)
{
printf(" ");
getch();
II.
217
return;
}
//
printf(" ->");
scanf("%s", &fam) ;
printf(" ->");
scanf("%s", &name);
printf(" ->");
scanf("%s", &tel);
/ /
fprintf(out,"%s %s %s", fam, name, tel);
puts(" ");
fclose(out);
//
printf("\\ <Enter>\n");
getch();
}
242
//
#include "stdio.h"
#include "conio.h"
#define FNAME "a:Wphone.txt\0" //
void main()
{
char fname[20] = FNAME;
FILE *in;
// -
char obr[15];
// -
//
char fam[15]; //
char name[15]; //
char tel [9];
//
int n = 0; // ,
puts(" ");
218
C/C'^^'^'
// () (t)
if ((in = fopen(fname, "rt")) == NULL)
{
p r i n t f (" %s", fnaitie) ;
getch();
return;
}
//
printf(" - > " ) ;
scanf("%s", &obr);
//
while (!feof(in))
{
fscanf(in,"%s %s %s", &fam, &name, &tel);
if (fam == obr)
{
printf("%s %s %s",fam, name, tel);
n++;
}
}
if (n )
printf(" : %i", n ) ;
else
printf(" %s ", obr);
fclose(in);
//
puts("\n <Enter>");
getch();
}
244
//
//
#include "stdio.h"
#include "conio.h"
#include "string.h"
II.
219
char fname[40]; //
FILE* f;
//
int VsegoVopr = 0 ; //
int PravOtv = 0 ;
//
//
int nOtv;
//
int Prav;
//
int Otv;
// ,
int ;
//
char St[80];
//
int i; //
if ( large )
{
puts("\nHe !");
puts(" : test ");
return;
}
strcpy{fname,argv[l]); //
// () (t)
if ((f = fopen(fnaine, "rt")) == NULL)
{
printf(" %s", fname);
getch();
retxim;
}
clrscr0;
puts(" .");
puts(" \
.");
puts(" ");
puts(" <Enter>\n");
printf
220
C/C+-i-
(" <Enter>");
getch();
textbackground(BLUE);
clrscr;
while (!feof(f))
{
VsegoVopr++;
fgets(st, 80, f);
printf("\n%s\n", St);
//
//
II.
221
245
//
// ,
// - ,
#include <stdio.h>
#include <dir.h>
#include <string.h>
#include <conio.h>
// tdefine DEBUG
//
/ /
// ,
void main(int argc, char *argv[])
{
struct ffblk ffblk; //
int done;
FILE *in;
//
int n;
//
char mask[MAXPATH];
char infile[MAXPATH];
char outfile[MAXPATH];
if (argc < 2)
{
puts("B ");
puts (" ");
printf (" : %s pathXWn", argv[0]);
return;
}
printf(" ");
//
strcpy(mask, argv[1]);
strcat(mask,"*.cpp");
// -
222
/-^-^
strcpy(outfile, argv[l]);
strcat(outfile,"filelist.txt");
247
// ""
#include "stdio.h"
tinclude "conio.h"
unsigned int factor (iinsigned int k)
{
if ( == 1 )
return(1);
else
return(k*factor(k-1));
}
223
v o i d main
{
iinsigned i n t n; / / ,
/ /
unsigned int f; //
puts(" \");
puts(" , ");
printf("->");
scanf("%u", &n);
f = factor(n);
printf(" %u %u", n, f);
printf("\ <Enter>");
getch();
}
248
//
tinclude <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
//
void elem(int x, int y, int r, int p)
{
// X, y, r
//
//
if ()
{
circle(, , );
delay(100);
elem(x+r, ,
/2, -1)
elem(x,
-, /2, -1)
elem(x-r, ,
/2, -1)
224
C/C-i-t-
elem(x,
+, / 2 ,
-1);
}
}
v o i d main (void)
(
int gdriver = DETECT; //
int gmode;
//
int errorcode;
//
initgraph(&gdriver, &gmode, PATHTODRIVER);
errorcode = graphresult();
if (errorcode == grOk)
{
elem(320, 240, 60, 5); // 5-
outtext(" <Enter>");
getch();
closegraph; //
}
else
{
intf(": %d\n", errorcode);
puts(" <Enter>");
getch();
}
249
//
// -
#include <stdio.h>
#include <conio.h>
float 1,2,; // ,
//
// -
float (int )
{
float ; // -1
II.
225
if (n == 1)
return(rl + 2 + );
else
{
= rcep(n~l);
return (rl + r2*r/(r2+r) + r3);
}
}
void mainO
{
int n;
float re;
// ()
//
puts(" ");
puts(" ():");
printf("rl ->");
scanf("%f", &rl);
printf("2 ->");
scanf("%f", &r2);
printf("r3 ->");
scanf("%f", &r3);
printf(" ->");
scanf("%i", &n);
re = rcep(n); //
// rcep
//
printf(" :");
if ( > 100)
{
/= 1000;
printf("%5.2f \", );
}
else
printf("%5.2f \", re);
puts("\n <Enter>");
getch();
226
/+-^-
250
//
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
// .
/ / ,
void drcep(int , int , int )
{
#define dx 7 // X
#define dy 7 // Y
setcolor(GREEN);
line(x,,x+2*dx,);
rectangle(x+2*dx,y-dy,x+6*dx,y+dy);
line(x+6*dx,y,x+8*dx,y);
outtextxy(x+3*dx,y-3*dy,"Rl");
setcolor(YELLOW);
line(x+8*dx,y,x+8*dx,y+2*dy);
rectangle(x+7*dx,y+2*dy,x+9*dx,y+6*dy);
line(x+8*dx,y+6*dy,x+8*dx,y+8*dy);
outtextxy(x+10*dx,y+2*dy,"R2");
setcolor(LIGHTGRAY);
line(x,y+8*dy,x+2*dx,y+8*dy);
rectangle(x+2*dx,y+7*dy,x+6*dx,y+9*dy);
line(x+6*dx,y+8*dy,x+8*dx,y+8*dy);
outtextxy(x+3*dx,y+5*dy,"R3");
if ( > 1 ) drcep(k-l, x+8*dx, y ) ;
}
void main (void)
{
int k; //
int gdriver = DETECT; //
II.
int gmode;
int errorcode;
227
//
//
251
//
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
tinclude <dos.h>
#define PATHTODRIVER "c: WborlandcWbgiW"
#define DT 3
#define 10
//
//
void Gilbert(int ); //
228
C/C++
II.
void ( i n t i)
{
if
( i > 0) {
d(i-l); my_lineto(getx() - u, getyO);
a(i-l); my_lineto(getx(), getyO + u) ;
a(i-l); my lineto (getx () + u, getyO);
b(i-l);
}
}
void b(int i)
{
if (i > 0)
{
c(i-l); my_lineto(getx(),gety0 - u ) ;
b{i-l); my_lineto(getx() + u, getyO);
b(i-l); my_lineto(getx(),gety() + u ) ;
a(i-l);
}
void (int i)
{
if (i > 0)
b(i-l)/
(1-1);
c(i-l);
d(i-l);
{
my_lineto(getx() + u,gety());
my__lineto(getx(), getyO - u) ;
my_lineto(getx() - u^getyO);
void ci(int 1 )
{
if (i > 0) {
a(l--l); my__lineto(getx() ,gety 0 + u ) ;
d(i-l); my_lineto(getx() - u,gety());
d(i-l); my lineto(getx(),gety() - u ) ;
c(i-l);
229
230
C/C-f-^-
//
void my_lineto(int 2, int 2)
{
int 1,1; //
// 2, 2
int ,;
//
int dx;
//
int dy;
//
//
int color; //
int a,b;
// -
int ;
// -
int i;
xl = getx();
yl = gety();
if ( xl != x2 )
{
//
a = (2-1)/(2-1);
b == yl- a * xl;
n = abs{x2-xl)+l;
if (x2 > xl)
dx = 1;
else dx = -1;
X = xl;
color = getcolor();
for (i = 1; i<= n; i++)
{
= a*x + b;
putpixel(x,y,color);
delay(DT);
X += dx;
}
}
else { //
n = abs(2-1);
if (2 > yl)
dy = 1;
else dy = -1;
X = xl;
II.
= 1;
color = getcolor();
for (i = 1; i<=n; i++)
{
putpixel(x, y, color);
delay(DT);
+= dy;
}
}
putpixel(x2, 2, color);
moveto(x2, 2);
252
//
#define u 5
// ,
#define DT 25 //
#define PATHTODRIVER ":\\borlandc\\bgi\\"
#include
#include
#include
#include
<graphics.h>
<stdio.h>
<conio.h>
<inath.h>
//
// : , ,
end
/I
void (int i);
void b(int i);
void (int i);
void d(int i);
//
//
#define linetodxy(dx,dy) lineto(getx()+dx,gety()+dy)
void far lineto(int x2, int 2); // no
//
// ,
//
231
232
C/C++
I/
v o i d ( i n t :L)
{
if
{
(i > 0)
a ( i - -1)
b ( i - -1)
d ( i - -1)
a ( i - -1)
linetodxy(u, u ) ;
linetodxy(2*u,0);
linetodxy(u, - u ) ;
}
void b(int i)
{
if (i > 0)
{
b(i-l);linetodxy(-u,u);
c(i-l);linetodxy(0, 2*u);
a(i-1);linetodxy(u,u);
b(i-l);
}
void (int i)
{
if (i > 0)
{
c(i-l);linetodxy(-u,-u);
d(i-l);linetodxy(~2*u,0);
b{i--l) ;linetodxy (-u,u) ;
c(i-l);
}
void d(int i)
{
if (i > 0)
{
d(i-l);linetodxy(u,~u);
a(i-l);linetodxy{0,-2*u);
(1-1);linetodxy(-U,-u);
II.
d(i-l);
}
}
v o i d main (void)
{
233
234
C/C'i"*'
getch();
}
//
// ,
//
#include <dos.h>
void far lineto(int x2, int 2)
{
int xl,yl; // ,
// 2,2
int ,;
//
int dx;
//
int dy;
//
//
int color; //
int a,b;
// -
int ;
// -
int i;
xl = getx();
yl = gety();
color = getcolor();
if ( xl != x2 )
{
//
a = (2-1)/(2-1);
b = yl- a * xl;
n = abs(x2-xl)+1;
if (x2 > xl)
dx = 1;
else
dx = -1;
X = xl;
for (i = 1; i<= n; i++)
{
II.
235
= * + ;
putpixel(,,color);
delay(DT);
X += dx;
}
}
else //
n = abs(y2"-yl) ;
if (2 > yl)
dy = 1;
else dy = -1;
X = xl;
= yl;
for (i = 1; i<==n; i++)
{
putpixel(x, y, color);
delay(DT);
+= dy;
}
}
putpixel(x2, 2, color);
moveto(x2, 2) ;
III.
+4- ,
main.
main.
main ,
:
int main(int argc, char* argv[])
{
/*
*/
return();
}
main
, :
void main()
{
/*
/+-^ :
( i n t .);
C/C-f--^
238
() (float .);
(char).
.
int
16
short int
16
unsigned int
16
0 ... 65 535
16
long
32
unsigned long
32
float
32
^-^^.-.^""
double
64
1,7x10-^... 1,7x10,+308
long double
80
3,4x10^
1.1 xlO^
unsigned char
0 ... 255
char
-128... 127
^^
char
.
ASCII {. ),
u n s i g n e d char.
III.
239
- .
:
cheu: [ ];
:
[];
:
[1]
[2];
.
(N-1), N
, .
""
+ +
X = X +
X = X -
X +=
X = X +
X -=
X = X
X *==
X =
X %=
X =
X %
if
1
if
{
240
C/C++
// ,
// ,
//
2
if ( )
{
// ,
// ,
//
}
else
{
// ,
// ,
//
switch
1
switch (
!: !;
case 2: 2;
breaJc;
break;
case KOHCTaHTaj: j;
;
default:
;
breaJc ;
2
switch ( )
case !: !;
case 2: 2;
break;
&;
case KOHCTaHTaj: j;
break;
III.
241
for
:
for ( ;
;
{
// ( )
}
.
,
.
, ,
. . .
.
, ,
.
do while
:
do
{
/ / ( )
}
w h i l e (
);
( ),
,
, ,
. ,
, . . .
while
:
while (
//
}
( )
242
/-^+
.
, . . ,
( ).
, ,
. ,
.
{ 1 !,
...
Tnnj
j)
//
/ /
return (
),
, ,
. , void.
return .
.
Tnnj, .
,
, . . *.
:
Courier;
, . . ,
;
.
,
;
,
, .
III.
243
abs, tabs
:
int
abs(int x);
double fabs (doijble x) ;
(abs) (fabs)
,
.
: <math.h>
, ,
.
-1 1.
: <math. h>
244
/++
, .
.
: <math.h>
, expl
:
double (double );
l o n g double (long doioble () ) ;
, (^,
).
: <math.h>
pow, powl
:
double pow (dovible x, doiable y) ;
l o n g double powl (long double ( x ) , l o n g dotoble (y) ) /
, .
: <math.h>
sqrt
:
double sqrt (double x) ;
, .
: <math.h>
rand
:
i n t rand(void);
RANDMAX. rand
.
srand.
III.
245
srand
:
void srand (unsigned x) ;
.
,
,
.
: <stdlib.h>
atof
:
doxible a t o f (const chau:* s) ;
,
.
, .
,
.
: <stdlib.h>
atoi, atol
:
int atoi(const char* s);
long atol(const char* s);
,
.
, ,
.
: <stdlib.h>
246
C/C-i-*-
govt
:
chsur *gcvt (double ,
int , char* );
.
,
,
.
: <stdlib.h>
,
.
.
,
.
( 2 36).
, itoa,
17 , i t o a ultoa 33 .
: <stdlib,h>
sprintf
:
i n t s p r i n t f (char * , const char* , );
.
, ,
.
.
///.
247
sprintf
printf, -, .
: <stdio.h>
-
printf
:
i n t p r i n t f (, ) ;
.
,
.
, , . .
(
).
%ni
%nd
%nu
%n.mf
%ns
.
m
,
,
\t
\\
\'
: <stdio.h>
248
C/C-^-f-
scant
:
int scanf (const chsur* , )
,
.
, . .
~
scanf
, .
%i
%d
%u
%f
%e
%s
%c
: <stdio.h>
puts
:
puts(const char* );
.
.
: <stdio.h>
gets
:
char * g e t s (chau:* s) ;
III.
249
.
.
: < s t d i o . h >
putch
:
i n t putch(int ) ;
.
: <conio.h>
getch
:
i n t getch(void);
.
, getch 0.
, , ,
, getch .
(~
getch ,
.
: <conio.h>
cputs
:
cputs(const char* );
.
t e x t c o l o r ,
textbackground.
~
\
\ \ , ' -
250
/-^-^
, .
c p r i n t f .
: <conio.h>
cprintf
printf, cpfintf
.
(
textcolor) (textbackground).
: <conio.h>
textcolor
:
v o i d t e x t c o i l o r ( i n t );
cputs cprintf
.
.
BLACK
BLUE
GREEN
CYAN
RED
MAGENTA
BROWN
LIGHTGRAY
DARKGRAY
LIGHTBLUE
LIGHTGREEN
10
LIGHTCYAN
11
LIGHTRED
12
251
III.
()
LIGHTMAGENTA
13
YELLOW
14
()
WHITE
15
: <conio.h>
textbackground
:
void textbackground(int );
, ,
cputs c p r i n t f .
.
BLACK
BLUE
GREEN
CYAN
RED
MAGENTA
BROWN
LIGHTGRAY
: <conio.h>
gotoxy
:
void gotoxy(int x, int y)
.
X , -
252
C/C++
, ,
.
: <conio.h>
clrscr
:
void c l r s c r (void)
,
textbackground.
: <conio.h>
window
:
void window(int xl,
i n t yl,
i n t x2, i n t 2) ;
. xi, yl
,
2,2 .
: <conio.h>
fopen
:
FILE* fopen(const char * , const char* )
,
.
. .
fopen
, ,
. .
III.
253
()
.
.
fopen ,
,
, ,
t. , r t ,
.
fopen
,
. -
, fopen NULL.
, ,
f e r r o r .
: <stciio.h>
fprintf
:
int fprintf(FILE * , , ) ;
(. p r i n t f ) ,
, .
, , ,
, (. fopen).
: < s t d i o . h >
fscanf
:
int fscanf(FILE * ,
const char* ,
);
(. scanf)
, ,
.
254
C/C-^-i-
, , ,
, (. f open).
: < s t d i o . h >
fgets
:
char* fgets (char '^,
int ,
FILE -^)
,
. ,
-!
.
.
, , ,
, (. f open).
: < s t d i o . h >
fputs
:
char* fputs(char * , FILE * )
.
, -, .
, , ,
, (. f open).
: < s t d i o . h >
terror
:
i n t ferror(FILE* )
,
.
: < s t d i o . h >
III.
255
feof
:
i n t feof(FILE* )
,
.
: <stdio.h>
fclose
:
i n t f c l o s e ( F I L E * )
.
: <stdio.h>
strcat
:
char *strcat(chaor* !,
c o n s t char* 2)
'! 2
!,
: <string.h>
strcpy
:
char * s t r c p y ( c h a r * !,
c o n s t char* 2)
! 2.
: <string.h>
strlen
:
int strlen(const char* )
256
C/C++
. .
: < s t r i n g . h >
strcmp
:
i n t s t r c m p (const char* !,
c o n s t char* 2)
! 2. ,
, , ! < 2
, ! > 2.
: < s t r i n g . h >
strlwr
:
char* strlwr(char* )
(
).
: < s t r i n g . h >
strupr
:
char* s t r u p r ( c h a r * )
(
).
: < s t r i n g . h >
strset
:
char* strset(char* , char )
.
: < s t r i n g . h >
257
III.
strchr
:
chco:* strchr(const char* , int )
, , NULL.
: <string.h>
arc
:
void arc (int , int ,
int ) ;
int ,
int
(, ).
- ,
.
.
.
.
, setcolor.
: <graph. h>
bar
:
void bar (int 1, i n t yl,
i n t x2, i n t 2) ,
258
C/C++
. 1 1
, 2
2 .
setfillstyle.
: <graph. h>
bar3d
:
void bar3d(int xi,int yl,int x2, int 2,
int , int _) ;
. xl yl
, 2 2
.
, _
, .
_ ,
.
(1.1)
^ ^
"(2,2)
III.
259
s e t f i l l s t y l e , s e t c o l o r .
: <graph.h>
circle
:
void circle(int , int ,
int )
(, ).
s e t c o l o r .
: <graph.h>
drawpoly
:
v o i d c l r a v o l y ( i n t ,
i n t * );
,
.
.
/
. '
( ),
. .
: <graph.h>
ellipse
:
void ellipse (int , int , int , nt
int , int ) ;
(, ).
, -
260
C/C++
.
.
.
.
,
setcolor.
: <graph.h>
getmaxx, getmaxy
:
int getmaxx (void) ;
int getmaxy (void) ;
getmaxx x
, getmaxy
.
: <graph.h>
getx, gety
:
int getx(void);
int gety(void);
x () .
: <graph.h>
graphresult
:
int graphresult(void);
III.
261
( )
. ,
.
: bar, bar3d, i n i t g r a p h ,
pieslice, setfillpattern, setfillstyle, setlinestyle,
s e t t e x t s t y l e .
: <graph.h>
grapherrormsg
:
chau:* grapherrormsg(int );
, ,
,
.
: <graph.h>
initgraph
:
void initgraph(int* Driver,
. Driver
, Mode
, Path .
(~
Driver
, DETECT.
i n i t g r a p h
.
: <graph.h>
iine
:
void l i n e (int xl,
i n t yl,
i n t x2, i n t 2) ;
262
C/C++
1, 1
2, 2.
setcolor,
s e t l i n e s t y l e .
: <graph.h>
lineto
:
void lineto(int x,
int y ) ;
, .
, s e t l i n e s t y l e .
, setcolor.
: <graph.h>
linerel
:
void linerel(int dx, int dy) ;
(xt,yt) (xt+dx, yt+dy), . .
.
,
s e t l i n e s t y l e . , s e t color.
(
getx gety.
: <graph.h>
moveto
:
void moveto (int x,
int y) ;
III.
263
.
: <graph.h>
moverel
:
void moverel (int dx, int dy) ;
dx dy .
dx (dy) ,
(), , ().
: <graph.h>
outtext
:
void outtext(const char* ) ;
-^
,
.
(
, o u t t e x t ,
, \ .
setcolor, s e t t e x t s t y l e .
: <graph.h>
outtextxy
:
void outtextxy(int x,'int
y, const char* )?
(, )
,
, . . (, ).
264
C/C++
s e t c o l o r , s e t t e x t s t y l e .
: <graph.h>
pieslice
:
void p i e s l i c e (int x, nt y, i n t , i n t ,
i n t ) ;
(, ).
,
.
.
.
, (, )
X. =0, =360,
p i e s l i c e .
,
s e t f i l l s l y l e , ,
s e t c o l o r .
: <graph.h>
putpixel
:
void putpixel(int , int , int );
III.
265
, (, ), .
(. s e t c o l o r ) .
: <graph.h>
rectangle
:
void rectangle(int xl,
i n t yl,
i n t x2, i n t 2);
. xl yl
, 2 2
.
( )
s e t l i n e s t y l e , --
setcolor.
: <graph.h>
sector
:
void sector (int x, int y,
int ) ;
int 1,
int 2,
int ,
{ )
{ = ) .
. 1 2
, ,
, "" .
,
(, ) .
1^0, 2=360, s e c t o r
().
.^
..^
..,
,_ ,
'^
. ^,
\
C/C++
266
s e t f i l l s t y l e ,
setcolor.
: <graph.h>
setcolor
:
void setcolor(int );
( o u t t e x t x y o u t t e x t ) ,
( l i n e , c i r c l e , r e c k t a n g l e
.).
.
BLACK
BLUE
GREEN
CYAN
RED
MAGENTA
BROWN
LIGHTGRAY
DARKGRAY
LIGHTBLUE
LIGHTGREEN
10
LIGHTCYAN
11
LIGHTRED
12
LIGHTMAGENTA
13
YELLOW
14
()
WHITE
15
: <graph.h>
III.
267
setfillstyle
:
void s e t f i l l s t y l e ( i n t , i n t );
(),
(bar, barSd, s e c t o r .).
, .
(. s e t c o l o r ) .
EMPTY_FILL
( )
SOLID_FILL
LINE_FILL
LTSLASH_FILL
45
SLASH_FILL
45
BKSLASH_FILL
45
LTBKSLASH_FILL
45
HATCH_FILL
XHATCH_FILL
45
INTERLEAVE_FILL
45
WIDEDOT_FILL
CLOSEDOT_FILL
USER FILL
: <graph.h>
setlinestyle
:
void s e t l i n e s t y l e (int , i n t , i n t );
268
C/C-i"f- /
(.
l i n e , c i r c l e .).
,
,
.
SOLIDLINE
DOTTEDLINE
CENTER_LINE
DASHEDLINE
, ,
DOTTED_LINE
USERBIT_LINE
.
( NORM_WIDTH)
( THICK_WIDTH).
,
s e t l i n e s t y l e ,
.
,
16 .
: <graph. h>
settexstyle
:
void settexstyle (int , int ,
int
);
, ,
o u t t e x t x y o u t t e x t .
.
DEFAULT_FONT
.
8 8 .
269
III.
()
TRIPLEX_FONT
Triplex
SMALL_FONT
SANSSERIF_FONT
SansSerif
GOTHIC FONT
, (DEFAULT__FONT),
.
,
o u t t e x t o u t t e x t x y .
(
HORIZ_DIR) , (
VERT_DIR).
: <graph.h>
delay
:
v o i d d e l a y (unsigned
);
.
: <dos. h>
sound
:
v o i d sound (unsigned );
.
. ,
nosound.
270
C/C-f"^
,
.
-, -
-, -
-, -
-, -
-, -
()
-, -
-, -
-, -
-, -
-, -
,
130
138,6
146,8
155,6
164,8
174,6
185
196
207,7
220
233,1
246,9
261,7
277,2
293,7
311,1
329,6
349,2
370
392,0
415,3
440
466,2
493,9
: <dos. h>
nosound
,
.
: <dos.h>
graph ,
, .
.
.
draw, otopa 16-
bmp-.
Microsoft Windows, ,
Paint.
tinclude <stdio.h>
#include <graphics.h>
/* draw
, -
() . ., 2001
int draw(int , int , char* fname)
{
/*
,
fname ;
:
>0 ;
-1 ;
-2
.
V
//
// Windows -> DOS
/-^-^
272
unsigned char color[16] =
{0,4,2,6,1,5,3,7,
8,12,10,14,9,13,11,15};
// ~ ,
// ;
//
struct bmpinfo
{
//
char hl,h2;
unsigned long
size,
// ,
reserved, // ,
//
offset.
//
//
width,
//
//
height;
unsigned int
plans,
// - , 1
bpp;
// - : 1, 4, 8 24
};
bmpinfo info;
//
FILE *f;
//
//
int ,;
unsigned char b; // ,
unsigned char bh; // 4
//
unsigned char bl; //
//
int nb;
// - ( )
//
int np;
// -
int i,j;
if ({f = fopenCfname, "rb")) == NULL)
return -1;
//
fread(& info, sizeof(info),1, f);
if (info.bpp != 4 )
return -2;
// 1-
X = xO;
= yO + info.height;
nb = (info.width / 8)*4;
if ((info.width / 8) != 0) nb += 4;
fseek(f, info.offset, SEEK_SET);
//
for (i = 0; i < info.height; i++)
{
np = 0;
// -
for (j = 0; j < nb; J++) //
{
b = fgetc(f);
if ( np < info.width)
{
bh = b 4;
putpixel(x,y,color[bh]);
X++;
np++;
}
if (np < info.width)
{
bl = b & 15;
putpixel(x,y,color[bl]);
X++;
np++;
}
}
x=xO;
y;
}
fclose(f);
return info.height;
273
UJr^CO
W:|:M>D^3D0
rSko
I
I
I I
I
i
I
t I
I
I
I
I
I
I I
OiHOsJCO^LO^or^-OOC^OTHCMCO^^LJO
I
I
I
I
I
I
I
i
I
I
i
I
I
I
I I
CsJCO-^LOVOr^OOCTNOiHCMCO-^MOVOr*
rHiH^tHTHTHTH^HCNJCMCNJCNJCNJCMCMCsJ
CNJC4JC41C\JCMCsJCNJC4JC\JC4JC4JCsJC\JCNJCMC\i
"
?
CD
+I
+,
OSJQ
U - D < - O-C-r-t-p^JsiJp-i E
I
I
i
I
I
I
I
I
I
I
I
I
I
I
I
I I
4Dr*COO>>CDiHC\J00^LO4Or^0OC^(S>THCSJ
o^o^o^o^ocooooooocr^1iiI
: D-1 - - - ' ' - <
l U I - 3 3 e - X : J T 3 a " d Q a j Q n ) S 2
OvUJ
OrHC^JCO-<iLOOr-OOa^
- V
II
Bs!=
1^==*^ I - i M I
I
H
I
/\C^-<3)
I
I
I
I
I
i
I
I
i
I
I
I
I
I
I
I
I I
ooa^Or^c\lco-^LODr-ooo^e?C^Jco^
^^***ooooooooooooooooooooo^c^G^
t~^
CN
oo
i
I
I
I
I
I
I
I
I
I
I
I
I
I
i
I I
\1^"*^01-1-1^-
4 0 * 0 4 0 4 0 4 0 4 0 * 0 4 0 4 0 P*-r** ** r**" r ^ ^ * *
(0
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I I
-<*Lo^or-ooo^r^c^Jco-dor-ooa^
^-<|--^-***<i'*^mLnLf>lOLr>L0L0L0L0L040
i
t
I
I
I
I
I
I
I
I
I
I
I
I
I
I I
4Dr^000>Or4CVJCr5^L04Dr-00C^THCVJ
THiHrHrHCMC\JC\]C\JC\JC\IC\JC4JC4IC\JCOC0Cn
CV4
THiHTHrHTHiHTHiHCMCSJCSJCNJCMCSJCSJCMCsi
tt
vo
0iHrHrHrHTHTHrHiHiHi-ICMCSJC\IC>JCM
CsJC4JC\JC\JC4JC4JC4lCMC\JC4JC\JC\iC\JCSJC41C\IC\J
it
II
I -t-
CVJC4JC41C\JCSJCsJC\ICNJC\JC\JCsJC\IC4JC\JCMC\JCM
tt
Q.
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
OTHC\JC0-d'L040r-00C^THC\JCD-d'm4D
a : Lo 00 L . d L U ^
pa
I
I
I i
I
I
I
I
I
i
I
I
I
I
I
i I
000S4HCslC0>d"L040r^00C7NO^C\J00-<d'
CslCNJCOa^COCOCOCOCOCOCOCO-<l'-^-^^^
CD s ^ s : 2> c=: z
c= a .
275
,
.
9.
,
.
, ,
. . , 2703 2 1000 + 7 100 4+ 0 10 + 1.
()
, ,
/- /- (. 1).
10^^=10000 ^
10^=1000
10^=^00
10^=10
10=1
2 7 5
. 1 .
.
. ,
.
/- /- (. 2).
,
.
276
C/C++
,
.
, .
.
2'=:128
2'=:4
2'=32
2^16
>
2^=8
2^=4
2^=2
2=1
1 1 0
0 1 1 0
1
7 6 5 4 3 2 1
1x128+1x64+0x32 + 0x16+ 1x8 + 1x4 + 0x2 + 1x1 =205
(11001101)2= (205) 10
. 2 .
, , ,
(
).
(. ).
.
,
,
. . 1
15 .
lOllloiOl
1
11
277
,
/
5
- .
1.
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
.
: 02, OxFF, 0x01.
1. ., ., .
. - .: , 1985.
2. . Turbo : . . .: , 1991.
384 : .
3. ., , . .
: . . .: , 1988. 512 : .
4. . : . . .:
, 1989. 360 : .
5. ., ., .
: . . .: , 1982.
386 : .
6. . .
: . . .: , 1986. 168 : .
7. . : .
. .: , 1985. 368 : .
8. / . . . . .
. . .: , 1989. 240 : .
41
65
:
63, 67
271
60, 62
60, 61
60
:
" " 51
" " 39, 50
35
47, 48
46
:
()
42, 43
44
44
44
60, 62
41
:
44
38
44
64
:
48
48
36
49
49
( . . 280)
280
():
49
36, 65
39
:
275
275
276
:
49
44
"" 44
44
40
:
63
63
63
:
abs 243
acos 243
arc 257
atof245
atoi 245
atol 245
bar 257
bar3d 258
circle 259
clrscr 252
cos 243
cprintf 250
cputs 249
delay 269
drawpoly 259
ellipse 259
exp 244
fclose 255
feof255
ferror 254
fgets 254
fopen 252
fprintf 253
fputs 254
fscanf 253
gcvt 246
getch 249
getmaxx getmaxy 260
gets 248
getx 260
gotoxy 251
grapherrormsg 261
graphresult 260
initgraph 261
itoa 246
line 261
linerel 262
lineto 262
Itoa 246
moverel 263
moveto 262
nosoiind 270
outtext 263
outtextxy 263
pieslice 264
pow 244
printf247
putch 249
putpixel 264
puts 248
rand 244
rectangle 265
scanf 248
sector 265
setcolor 266
setfillstyle 267
setlinestyle 267
281
settexstyle 268
sin 243
sound 269
sprintf 246
sqrt 244
srand 245
strcat 255
strchr 257
strcmp 256
strcpy 255
strlen 255
strlwr 256
strset 256
strupr 256
tan 243
textbackground 251
textcolor 250
utoa 246
window 252
"" 41
63
276
48, 276