!= ( )
, ,
. ( -
a<b==c<d 1 , a<b c<d
).
,
- ,
0. , , -
0,
0; -
.
4.8. ''
_:
&
& , &
. -
;
'' .
.
4.9. ''
__:
^
^ ( , -8 0136)
, ^ -
.
; -
'' . -
.
4.10. ''
__:
|
-17-
| , |
. -
;
'' .
.
4.11. ''
__:
&&
&& . 1,
, 0 -
. & &&
; , 0, -
.
,
, -
. int.
4.12. ''
__:
||
|| . 1,
, 0 -
. | || -
; ,
, .
,
, -
. int.
4.13.
_:
? :
.
, ,
;
.
, -
, ,
; ,
, ;
,
- 0, -
. -
.
-18-
4.14.
,
.
l_, -
.
,
, .
.
_:
l_ =
l_ +=
l_ -=
l_ *=
l_ /=
l_ %=
l_ >>=
l_ <<=
l_ &=
l_ ^=
l_ |=
'=',
,
l_. ,
.
e1 = e2, - -
,
e1 = e1 (e2), , e1 -
. += -= -
, ()
,
. 0.4;
.
-
, -
. -
- .
-
,
. , -
0 ,
.
-19-
4.15.
, -
.
.
4.16. '<
__:
,
, , -
. -
.
. ,
, , ,
-
, , ,
; ,
f(a,(t=3,t+2),c)
, 5.
4.17. .
. ,
, ;
. , -
, *, "/" "%" -
, , "+" "-".
-20-
2
------------------------------------------
| | |
|____________________|___________________|
| () [] -> . | |
|____________________|___________________|
| ~ ++ -- - f | |
|(type) * & sizeof| |
|____________________|___________________|
| * / % | |
|____________________|___________________|
| + - | |
|____________________|___________________|
| << >> | |
|____________________|___________________|
| < <= > >= | |
|____________________|___________________|
| == != | |
|____________________|___________________|
| & | |
|____________________|___________________|
| ^ | |
|____________________|___________________|
| | | |
|____________________|___________________|
| && | |
|____________________|___________________|
| || | |
|____________________|___________________|
| ?: | |
|____________________|___________________|
| = += -= .. | |
|____________________|___________________|
| , | |
|____________________|___________________|
,
&, ^ | == !=.
, ,
if (( & mask) == 0) ...
, :
: x & mask == 0
: x & ( mask == 0 )
-21-
* 5.
, -
; -
, .
:
_ _;
-
. -
.
_:
_ _
__ _
c_... - _...
, -
.
5.1.
:
__:
auto
static
extern
register
typedef
typedef
" "
; .
(. " ").
auto, static register
, -
. extern
-
, .
register
auto ,
. -
. ,
-22-
; CM- int, char .
:
&. -
-
, -
-
.
3 -
register .
.
, , auto,
, extern
. :
.
5.2.
.
_:
char
short
int
long
unsigned
float
double
___
_
__
long, short unsigned -
; :
short int
long int
unsigned int
long float
, double. -
. , -
, int.
.
0.5, - .0.6;
typedef . 0.9.
-23-
5.3.
,
.
_:
_
_,-
_
_:
.0.6.
,
. :
:
( )
*
()
[-]
, .
5.4.
,
, ,
,
.
; ,
.
-
, , -
.
,
. .
t di
t - ( int ..), di - -
. , ,
...t, "..."
, di (
-24-
int int). , di
*d
...
t.
di
d()
... , -
t.
di
d[_]
d[ ]
... t. -
, -
int. (
). " "
, ;
, ,
-
. , -
,
, . -
, -
. -
.
, ,
( -
).
,
, .
:
,
; , -
. , -
,
.
-25-
int i, *ip, f(), *fip(), (*pfi)();
i, ip , -
f, , fip, -
, pfi , -
. -
. *fip() *(fip()),
,
fip -
() . (*pfi)()
, , -
, ,
, ;
.
float fa[17], *afp[17];
float -
float. ,
static int 3d[3][5][7];
3*5*7. : 3d -
; ;
.
3d, 3d[i], 3d[i][j] 3d[i][j][k] -
.
"", int.
5.5.
- ,
.
. - ,
.
.
___:
__ { -
__ }
___-
{ -- }
___
__:
struct
union
-26-
__ -
:
__:
_
_ -
__
_:
_ -
__
__:
_
_,_-
_
-
.
.
;
.
_:
: _
: _
, -
. ,
, ,
; -
. , ,
; . ,
, -
.
CM-, .
, ,
, ,
.
0
.
, " "
, ,
.
,
, -
- . ,
-27-
int . CM-
-
.
&,
.
,
0 -
, .
.
,
.. :
struct {__}
union {--}
(
) , .
,
struct
union
, -
; -
. ,
, -
-
, .
-
.
.
-
; ,
, -
. -
,
,
, .
:
-28-
struct tnode {
char tword[20];
int count;
struct tnode *left;
struct tnode *right;
};
20 ,
.
,
struct tnode s, *sp;
, s ,
sp .
sp->count
count , sp;
s.left
s,
s.right->tword[0]
tword
s.
5.6.
. -
:
_:
enum _
enum _
enum
_:
_,
:
=
-29-
_ -
_; -
. ,
enum color {red, white, black, blue };
. . .
enum color *cp, col;
color ,
c
, col - .
_ -
, ( )
.
( =), 0 -
1
. = -
; -
.
-
.
, , -
lint .
CM_
, int.
5.7.
-
.
, -
=.
:
=
= {_}
= {_,}
_:
_,_
{_}
_ - _
-30-
,
, -
, , -
, (,
) .
, -
.
,
0;
.
(
),
, . -
;
, .
(-
), -
-
.
. ,
.
, .
.
.
, -
; ,
, .
, -
; -
,
. ,
.
-
char .
.
,
int [] = {1,3,5};
; -
,
-31-
, ,
.
-
:
float *y[4][3] = {
( 1, 3, 5 ),
( 2, 4, 6 ),
( 3, 5, 7 ),
};
1, 3 5 y[0],
y[0][0], y[0][1] y[0][2]. -
y[1] y[2].
, , , y[3]
.
,
float y[4][3] = {
1, 3, 5, 2, 4, 6, 3, 5, 7
};
y ,
y[0] . 3
.
y[1] y[2].
float y[4][3] = {
{1}, {2}, {3}, {4}
};
y (
), .
,
char msg[] = "syntax error on line %s\n";
.
5.8.
(
sizeof)
. -
" ",
,
.
-32-
:
_ _
_:
(_)
*
_ ()
_ [-
]
(_)
, _ .
_, ,
. -
-
. ,
int
int *
int *[3]
int (*)[3]
int *()
int (*)()
"", " ",
" ", "
", " , "
" , ".
5.9. typedef
, " "
typedef, .
, -
, ,
.
__:
typedef , ,
,
, .
0.4 . ,
typedef int miles, *klicksp;
typedef struct { double re, im;} complex;
-33-
miles distance;
extern klicksp metricp;
complex z, *zp;
; distance
int, metricp - " int", z -
zp -
.
typedef -
, ,
. -
distance
, ,
int.
* 6.
,
.
6.1.
-
,
;
.
6.2. ( )
, -
,
, (
""):
:
{_ _}
_:
_
_:
_
- _
-34-
, -
.
-
.
( )
; -
. -
, -
.
-
, .
6.3.
:
if ()
if () else
,
, . ,
, .
, else
else if, else.
6.4. while
while
while ()
,
.
.
6.5. do
do
do while ()
,
.
.
6.6. for
for
(1;2;3)
-35-
for :
1;
while (2) {
3;
}
,
; , -
, ,
;
,
.
.
, while -
while(1);
.
6.7. switch
switch (),
,
.
switch ()
-
, int. -
.
case, -
:
case :
int.
.
.
, -
default:
switch
-
.
, -
, .