Руденко-задачник По С

  • Upload
    -

  • View
    68

  • Download
    0

Embed Size (px)

Citation preview

. ..

..

.

( II )

1999

519.682

. ANSI- .

. , . (., , 1992) .

, .

.

:

. ..

. ..

.. ( II ).

( 040777 23.07.96), 1999.-80 .

- . ..

ISBN 5-89407-048-1

. .., 1999

1.

. . [1], . , - ( 1.7 1.8 [1]). . . ; ANSI (X3.159 - 1989) [2].

, , .

, , UNIX , .

2. , ,

2.1. , ? , .

123

1E6

123456789LU-5

0XFUL

0

058

\x7

0X-1AD\122

001230xffffffL01A

-x

(x(aU

0731UL\n

+0xaf

0X0

2.2. ? , .

1.71

1E-6

0.314159E1F

.005

0051E-04

5.E+20e0

0x1A1.5

05.5

0

0X1E60F

1234.56789L

1.0E-10D3.1415U

1e-2f

-12.3E-6+10e6

123456LE-6

2.3. ? ( + - * / % = ):

int a, b, c, d, e;

a = 2; b = 13; c = 7; d = 19; e = -4;

b / a / c

d / a % c

c % d-e-e % a + b / a (-5+5

b % e

7-d%+(3-a)

b % - e ( c9 / c - - 20 / d

2.4. : 1; , .

int a, c; c = 5;

a). c ++ ;

b). a = 2 ( c++ ;c). c += 1;

d). a = c++ + c;

a = 2 ( c;

a = c + c;

e). ++c;

f). a = ++ c + c;g). a = c += 1 + c;h). a = (c+=1)+c;

a = c + c;

2.5. : 1; , 2.

int a, c; c = 5;

a). -- c ;

b). a = -- c / 2;c). c -= 1;

d). a = c -- / 2;

a = c / 2;

a = c % 2;

e). a = c -= 1/2;f). a = (c = c - 1)/2;g). a = (c -= 1)/2;h). a=(c-= 1)/2.0;

2.6. ?

a) E1 op= E2

E1 = E1 op E2

b) E1 op= E2

E1 = E1 op (E2)

: E1, E2 - ; op - ( + - * / % >> = k+1

i + j++ + k = = -2(j

m = 3 < j < 5

m = 3 = = j < 5

m = = c = w

m = c != 87

m = c = ! 87

m = ! c = 87

m = !c+87

! m = =c + 87

m ! = c + 87

k = = j - 9 = = i

k (= 3 + j

i + j = !k

i += ++ j + 3

k %= m = 1 + n / 2

1 + 3 ( n += 7 / 5

1 + 3 ( (n += 7) / 5c + i < c - x+10

i - k = = 0+9 < 10

2.9. :

not (not x) = x

x and true = x

! && ? .

2.10. y > 0 x < x + y . ?

2.11. , !! ( a>b )

! ( 2(a == b+4 )

! ( a 0. 2/( ((1/2) *((1/2+1/2((1/2))*((1/2+ 1/2((1/2+1/2((1/2)))*... . , ( , eps.3.42. x n :a) sin x + sin2x + ... + sinnx b) sin x + sinx2 + ... + sinxn c) sin x + sin(sin x ) + ... + sin ( sin (... sin(sin x) ... ))3.43. () : m n - m ( n. , n = 0, (n, m) = m, n ( 0, m, n, r, r - m n, (m, n) = (n, r). , a b.3.44. 1 - 1/2 + 1/3 - 1/4 + ...+1/9999 - 1/10000 : a). ;b). ;c). 1 +1/3 + 1/5 + ... + 1/9999 1/2 + 1/4 + ... + 1/10000, ;d). 1 +1/3 + 1/5 + ... + 1/9999 1/2 + 1/4 + ... + 1/10000, . .3.45. , , . - n. , n.3.46. , , 10000, .3.47. p q - q = p+2, (twin primes). , 3 5 - . , N.3.3 : .3.48. , ( ASCII):a) , a;b) , e u ( e , u );c) , - n o, .. n o o n;d) , + -, ;e) , , ++;f) , , char;g) , , ( ), . , . , ;h) , , . . , , ;i) , , : ::= + | ::= | ::= | | ::= A | B | C | D | E | F | G | H | I | J | K ::= 0 | 1 | 2 | 3 | 4 | 5 ::= | 3.49. , ( ASCII). , :a) ? !;b) - &;c) , ;d) ( );e) ( );f) + ;g) n ( n/2 + ( n >= 2 ); ( ;h) ( , );i) the;j) , ; ( );k) child children;l) , { }. . , , .3.50. , $ ( ASCII). , :a) , , , (, a+12.3456-b-0.456789+1.3-45678 a+12.34-b-0.45+1.3-45678);b) , , ( , , ; , a-000123+bc+0000.0008-0000+0001.07 a-123+bc+0.0008-0+1.07).4. 4.1. , ANSI . ?4.2. , void. .4.3. , . ? ? .4.4. ? , ; , .4.5. ? - ?4.6. , ( , declaration ) ( definition) . . [1, . .71]. .4.7. :a) double f ( );double f (void);b) char g ( int i, char c);char g ( int, char);c) h ( double x);int h ( double x);d) void h ( int );h ( int );e) extern int q ( int );int q ( int);f) static void s ( char c);void s ( char c);4.8. , , ; :int i;char c = a;extern int f ( int, char );static int j;register int b;double g( ) { return 3.141592; };extern long k;int h ( int i );static char q( int, double );auto short n;s();static void p( int i ) { };4.9. :a) return b) , ( void), return;c) , , return E; , d) , , return E; e) f) , , ; ,void f(void) { ... label: S1; ... { ... label: S2; ... goto label; ...} ... goto label; ... }g) ( ) ; , void f(void){... g();...} void g(void){...f();...}, , , .h) , ; , , , ( ) i) , - , , j) #include int f(void) { return 100;}void g(void) { printf("O.K.\n");}main() { int i, j; i = f(); j = g(), f(); g(); f(); printf("i=%d, j=%d f=%d\n", i, j, f()); }4.10. ? ? ? 4.11. ? "" - ; "" - .a) #include b) #include main() main() { int i; int sum = 0; { int i; int sum = 0; for ( i = 1; i x = a; pp -> y = b; return pp;}d)struct point (create_point ( int a, int b){ struct point (pp; pp = (struct point () malloc(sizeof(struct point)); pp -> x = a; pp -> y = b; return pp;}6.13. :struct point { int x; int y;} , , , ;6.14. a) ;b) ;c) ;d) . ; .6.15. :struct point { int x; int y;};struct circle { int radius; struct point center;}; struct circle plane [50], . , a) ;b) ( ) ;c) ;d) , .. plane. 6.16. , , dictionary:#define MAXSIZE 1000#define LENGHT 20 /( (/struct elem { char ( word; struct info (data;};struct info { int count; /( (/ char (alias; /( (/ };struct { struct elem (tabl [ MAXSIZE]; int number; /( (/}dictionary; (word) ; (alias) . , a) : NULL:1) ;2) ;b) ; , ; :1) ;2) ;c) :1) ;2) ;d) () ; , , :1) ;2) ;e) , . 6.17. (. ). a)strut elem (add_word ( char ( word, char (alias), dictionary (, , );1) ;2) ; .b)strut elem (update_word ( char ( word, char (alias), (, );1) ;2) ; , .c)struct elem (delete_word ( char (word), ; , NULL, ;1) ;2) ;6.18. . . .6.19. ? "" - , , ; "" - .#include struct data { char (s; int i; struct data (dp; };main() { static struct data a[ ] = { { "abcd", 1, a+1 }, { "efgh", 2, a+2 }, { "ijkl",3, a } }; struct data (p = a; int i; printf("a[0].s=%s p -> s=%s a[2].dp -> s=%s\n", a[0].s, p -> s, a[2].dp -> s); for ( i = 0; i < 2; i++ ) printf("--a[i].i=%d ++a[i].s[3]=%c\n", --a[i].i, ++a[i].s[3]); printf("++(p->s)=%s\n", ++(p->s) ); printf("a[(++p) -> i].s=%s\n", a[(++p) -> i].s); printf("a[--(p -> dp -> i)].s=%s\n", a[--(p -> dp -> i)].s); }6.20. struct s { int k; float (f; char (p[2];};struct s (ps; ps , :char str[5] = abcd;ps = (struct s () malloc(sizeof(struct s));((ps).k = 5;ps -> f = (float () malloc(sizeof(float)); ((ps -> f) = 3.1415;((ps).p[0] = (char() malloc(5(sizeof(char));((ps).p[1] = (char() malloc(10(sizeof(char));((ps).p[0] = str;((ps).p[1] = abcdefghi;6.21. q , :struct data { double ((p; char (s; int (a[2]; };struct data (q;6.22. a , :struct b { double (q; int ( ((p)[2]; };struct b ((a[1];6.23. x , :struct r { double (a[3]; char ((s; union { int i; float f; } u; }struct r x[2];6.24. x , :struct a { char (((s; char ((p)[2]; };typedef struct a ( data;data x[2];6.25. pt , :struct t { int ((pi; double ((k)(double,int(); char (p[2]; };struct t (pt;6.26. a , :struct data { int (i; int ((f)(int); char ((s; };struct data a[2];6.3 : 6.27 6.40 ( );struct lnode { type data;/( (/ struct lnode (next; /( (/ } struct lnode . , , . type .6.27. , a) ;b) ;c), .d) ; int .6.28. , a) ;b) ( );1) ;2) ;c) ( );1) ;2) ;d) . - double(, .6.29. , , . int.6.30. , . - double.6.31. , . - char(.6.32. , L2 - L1.struct lnode {struct data (p;struct lnode (next; };struct data { double f; char (s[2];};6.33. , , .struct lnode { struct data (p;struct lnode (next; };struct data { double f; char (s[2];};6.34. , , L1 L2. - char(, , .6.35. , L1 L2, L3:a) L3 L1 L2;b) L3 L1 L2; L1 L2 . - int(.6.36. , E ( data) L1 L2, .struct lnode { struct data ( dtpr; struct lnode (next; };struct data { int i; char (s; };6.37. , , . - char(.6.38. , L3, L1, L2.a) L3 L1;b) L3 L1; L1 . - int(.6.39. , L3, , L1 L2. L3 L1 L2; L1 L2 . - char(.6.40. , L3, , (L1 L2), . L3 L1 L2; L1 L2 . - char(.: 6.41 6.44 (). , , . , ( , ). , , , , .6.41. ( , ). ( , , , ..). .6.42. : , ( , ).6.43. : , .6.44. , ( ) . .: 6.45 6.47 ;struct tnode { type data;/( (/ struct tnode (left; /( (/ struct tnode (right; /( (/ } struct tnode . , , . type .6.45. 6.42 6.43 , , a) ;b) ;c) ( ) , ( , -1);d), (.. , , , );e) N- ( );f) , , . int .6.46. , a) ;b) ;), ;d) , ;e) , ; int .6.47. , ( . 6.45(d)).6.48. . .7. -7.1 -7.1. . i, n (i ( n), a1, a2, ,an. , ai.7.2. . a1, a2, ,a50. a1, a2, ,a50 , , , ai = ( ai-1 + ai + ai+1 )/3 i = 2, 3, ,49;, a) , , ;b) .7.3. . a1, a2, , a1 > 0 a2, a3, . a1, a2, ,an - , ( n ). a) a1 + a2 + +anb) a1 ( a2 ( ( anc) a1, a2, ,and) a1 , a1 ( a2 , a1 ( a2 ( a3 ,, a1 ( a2 ( ( ane) a1 + 2(a2 + 3(a3 + + (n-1)(an-1 + n(anf) | a1 - a2 |, | a2 - a3 | , , | an-1 - an |, | an - a1 |7.4. . n, a1, a2, , an(n ( 4). , a1, a2, , an - n 100 . 4(100, .. , .7.5. : , ; , a) ... i = 0; while ( getchar() < getchar() ) i = i + 2;b) i = 0; c = getchar(); while ( c < ( c = getchar() ) ) i++;c) i = 0; c = getchar(); while ( c < ( d = getchar()) ) { i++; c = d;}d) i = 0; c = getchar(); while (d = getchar(), c f.rese)pr1 < f.dat | pr2 | pr3 > f.resf)pr1 | pr2 >> f.resg)pr1; pr2 | pr3 > f.resh)( (pr1 | pr2); pr3) | pr4i)pr1 arg1 < f.dat; pr2 | pr3 >>f.resj)pr1 arg1 < f.dat | pr2 | pr3 >f.res &k)pr1 arg1 > f.res ; pr2 | pr3 >> f.res l)pr1 < f.dat | pr2 arg2 ; pr3 > f.res m)pr1; pr2; ... ; prnn)pr1; pr2; ... ; prn &o)pr1 | pr2 | ... | prnp)pr1 | pr2 | ... | prn &8.19. , SHELL pr1&&pr2 ( pr1; pr1 pr2, ). .8.20. , SHELL pr1 || pr2( pr1; pr1 pr2, ). .8.21. , (pr1;pr2) | pr3 > f.res ( pr1 pr2 pr3; f.res; pr1, pr2 pr3 -).a) pr1 pr2 pr3 f.resb) (pr1;pr2) | pr3>f.res .: strtok 8.22. , n . , , : _ _ , pr1 3 a1 a2 a3 pr2 0 pr3 2 b1 b2 , pr1 a1 a2 a3 | pr2 | pr3 b1 b2.8.23. exp_x -, exp(x). exp_x - x exp(x). , exp(xi) [a,b] xi=a+i*h, i = 0, 1, ..., n; h = (b-a)/n. a, b n . .8.24. func -, f x. - x f(x). , f(x) [a,b] xi =a+i(h, i = 0,1,...,n; h = ( b-a )/n. a, b n . f.tab.8.25. modify, ( ; ). modify. , modify , . , ; . , modify ( modify).8.26. modify, ( ; ). modify. , modify , . , , , ( a z ), , - . sort.8.27. , , , N- . , wc. . N .8.28. , , . sort. . .8.29. , , , , - . wc grep. . - .8.30. , fk, nk , strk . fk, nk - strk f1 n1 str1 f2 n2 str2 ... fk nk strk. grep wc.8.31. file_dbl, 128 . file_dbl. , file_dbl , . 1024 , file_dbl, . , file_dbl ( file_dbl).8.32. . ./. ( ). . . .8.33. ?#include void Start ( char *name, int in, int out) { if (fork() == 0) { dup2(in,0); dup2(out,1); close(in); close(out); execlp(name,name,0); } }main(int argc, char *argv[]) { int i, fd[2], in=0, out; for ( i = 1; i < argc-1; i++) { pipe(fd); out=fd[1]; Start(argv[i], in, out); close(in); close(out); in = fd[0]; } out = 1; Start(argv[ i ], in, out); }8.2.2. .8.34. "-" . 1, 2, 3, 4 .. Ctrl+C.8.35. "-" (. ) . . Ctrl+C.8.36. "" : "1", - "2", - "3", - "4" .. Ctrl+C. .8.37. "" (. ). Ctrl+C. .8.38. : 1, 'a'; 2, - 'b.' 3, - 'c'; 4, - 'd' .. 'a' 'z' . Ctrl+C. .8.39. , . , . ( Ctrl+C: - ). .8.40. , N . ( , N -) . ( Ctrl+C: - , ).8.41. ( , + - ). . - . .8.42. , . , , . . ( Ctrl+C: ; , -. , wc).8.43. . - N- ( , -). N . ; N -. .8.44. f(x) = 0 eps > 0 [a,b] ( : , , , ), Ctrl+C :C - ;A - ;R - ( a b ). . ( eps) Ctrl+C, , .8.45. f(x) [a,b] eps ( : , , ), SIGFPE ( : 0 ) , :A - ;R - ( a b ; SIGFPE ). . ( ) , , .8.46. . . , N, - . , :D - C - N A - . , , , . N .8.47. , . /. ( ) . Ctrl+C , - , - , . (, ) Ctrl+C, , -.8.48. , N : Ctrl+C. N .9. 9.1 1. , short, int, long, float, double long double.2. char: signed- unsigned- .3. , : ( , u/U, l/L, , ) ( , , f/F, l/L, e/E ) ( , )4. , '0'-'9', 'a'-'z', 'A'- 'Z', ( ).5. : 6. , ; .7. , (, , ; , ).8. % .9. , == != , .10. , " " , .. , "" .11. , sizeof, , ; - .12. , "" int ( int "" ).13. , unsigned- "" ( unsigned int "" int, - unsigned int ).14. , (M- ) (N- ) M > N, M = N, M < N.15. , (M- ) (N- ) M > N, M = N, M < N.16. , ( X ) ( N- ) | X | < 2N-1, | X | >= 2N-1.17. , X(M- ) ( N- ) M > N, M = N, M < N; X >= 0, X < 0.18. , (M- ) ( N- ) M > N, M = N, M < N.19. , ( X ) (N- ) 0= 2N.9.2 , , . , , . . :- ( / )- - - - ( ). +, - ,(, / ; ; ( ) . , 6 ; , .. _._, , . ( ). . . :- , setjmp longjmp.- (). ; .- ( ).- , .. int double. : .9.3 SHELL( My_Shell) : SHELL ( ). : 1. , .. - , ( - );2. ;3. My_Shell.!!! "" (, -) . (): ( ): # pr1 | pr2 | ... | prN N>=2; , prI (1 ( pr1 prN ),pr < data > respr1 | pr2 > res.txt # & ( ),pr arg1 arg2 &pr1 | pr2 | pr3 > res.all & : ( ) , . . , , ; . .I. 1. mv old_file new_file2. cp file copy_fileII. 1. wc filename: filename ( ; )2. grep substring filename: filename, substring ( -v; - , substring )3. cmp filename1 filename2: , filename1 differs from filename2: line 5 char 36*4. sort filename ASCII :-r -f -n +n (n+1)- III. 1. cat filenames :-n ( , )2. tail filename 10 :-nn +n n- 3. od filename 10 ,000001 a b c d \n e f g h i000011 j k \t l m n :-b IV. 1. pr1 ; pr2 ; ... ; prN prI - !!! | , ; , : , ( pr1; pr2 ) | pr3, pr1 pr2, pr3 .2. pr1 && pr2 pr1; pr23. pr1 || pr2 pr1; pr210. 10.1 , ANSI- C. [1] [2].10.1.1 . , , . unsigned char.char *strcpy(char *s, const char *ct) ct s, \0; s.char *strcat (char *s, const char *ct) ct s; s.char strcmp(const char *cs, const char *ct) cs ct; 0, csct.char *strchr(const char *cs, char c) c cs , , NULL.char *strrchr(const char *cs, char c) c cs , , NULL.char *strstr(const char *cs, const char *ct) ct cs , , NULL.size_t strlen(const char *cs) cs ( \0).char *strtok(char *s, const char *ct) s , ct. strtok s . , ct. s NULL. s , , ct; , \0 . strtok, s NULL, , . NULL, . ct .void *memcpy(void *s, const void *ct, size_t n) n ct s s.void *memset(void *s, char c, size_t n) c n s s.10.1.2 , , . int unsigned char, int, EOF; int. (), , () .int isupper (int c) int islower (int c) int isalpha (int c)isupper(c) islower(c) int isdigit (int c) int isalnum (int c)isalpha (c) isdigit (c) int isxdigit (int c) int isspace (int c), -, -, int isgraph (int c) , int isprint (int c) , , .int tolower (int c) , tolower(c) ; c.int toupper (int c) , toupper(c) ; c.10.1.3 - - ; - . : . - . \n. - , , , , , -, , . UNIX . ; . FILE, , . , . , : stdin, stdout stderr. , -, .10.1.3.1 FILE *fopen ( const char *filename, const char* mode ) fopen NULL, . :r w ; ( ) a r+ (.. )a+ ; fflush . b (, rb a+b), , .FILE *freopen ( const char *filename, const char* mode, FILE *stream) freopen stream. stream , , NULL. freopen , stdin, stdout stderr, .int fflush ( FILE *stream) fflush , ( ) . . EOF, , . fflush (NULL) .int fclose ( FILE *stream) fclose , , , . EOF .int remove(const char *filename) remove ; . .int rename(const char *oldname, const char* newname) rename oldname newname; , , - .10.1.3.2 .int fprintf ( FILE* stream, const char* format,...) stream format. - , , . , , , , . % - . % - ( , ): -, ;+ ; - , ;0, ;( : 0; 0 0; e, E, f, g G ; g G . , . , . , , , ; - ( , ). ( , ). , . , , , , e, E f, g- G-, ( ). h, l L. h , short unsigned short; l - long unsigned long; L - long double.- ------------------------------------------------------------------------------------------------------- ; ------------------------------------------------------------------------------------------------------- d,iint; . int; ( 0). x,Xint; ( 0x 0X), 10 15 abcdef x ABCDEF X. uint; . cint; unsigned char. schar *; , \0 - , . fdouble; [-]mmm.ddd, d - . 6; . e,Edouble; [-]m.dddddde(xx [-]m.ddddddE(xx, d . 6; . g,Gdouble; %e %E, 4 - ; %f. - . pvoid*; ( -). % ; %int printf ( const char* format,...) fprintf (stdout, const char* format,...)int sprintf (char *s, const char* format,...)sprintf , printf, s, \0. s , . ( \0).10.1.3.3 .int fscanf (FILE* stream, const char* format,...) stream format. , format. . , . EOF, ; - . , . % - . % - ( , ): *, ; , ; h, l L. - d, i, o, u, x h, short ( int), l, - long. - e, f, g l, - double ( float), L, - long double. , - , , ( %), , . , , -, -, - -. . ; , . , . *, , .- ------------------------------------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------------------------------------ d ; int *. i; int *. ( ) ( 0 0). ( 0 ); int *. x ( 0x 0X ); int *. u ; unsigned int *. c; char *. , ; 1. \0 . - . , %1s. s ( ); char*, - , , \0. e,f,g ; float *. , ( , ) , E e - (, ). p , printf %p ( ); void*. % %; .int scanf ( const char* format,...) fscanf (stdin, const char* format,...).int sscanf (char *s, const char* format,...)sscanf , scanf, s.10.1.3.4 - int fgetc (FILE *stream)fgetc stream unsigned char, int, EOF, .char *fgets (char *s, int n, FILE *stream)fgets n-1 s, , -, ; , \0. fgets s NULL, .int fputc ( int c, FILE * stream)fputc c, unsigned char, stream. EOF .int fputs (const char *s, FILE * stream)fputs s, \n, stream. EOF.int getc (FILE *stream)getc , fgetc, ; stream .int getchar (void)getchar() , getc(stdin).char *gets (char *s)gets s, - \0. s NULL, .int putc (int c, FILE *stream)putc , fputc, ; stream .int putchar (int c)putchar(c) , putc(c,stdout).int puts (const char *s)puts s - stdout. EOF; - .int ungetc (int c, FILE *stream)ungetc c ( unsigned char) stream; stream . . EOF. ungetc , , EOF.10.1.3.5 int fseek (FILE *stream, long offset, int origin)fseek stream; . offset , origin. origin 0 ; origin 1, ; , origin 2. offset , ftell. offset fseek.long ftell (FILE *stream)ftell stream -1L, .void rewind (FILE *stream)rewind(fp) , fseek(fp,0L,SEEK_SET); clearerr(fp).int fgetpos (FILE *stream, fpos_t *ptr)fgetpos stream *ptr fsetpos. fpos_t . fgetpos .int fsetpos (FILE *stream, const fpos_t *ptr)fsetpos stream, *ptr, fgetpos. fsetpos .int feof (FILE *stream)feof , stream .void clearerr (FILE (stream)clearerr stream.10.1.4 :double sin(double x) xdouble cos(double x) xdouble tan(double x) xdouble asin(double x) x; x([-1,+1]double acos(double x) x; x([-1,+1]double atan(double x) xdouble sinh(double x) xdouble cosh(double x) xdouble tanh(double x) xdouble exp(double x) exdouble log(double x) ln(x), x>0double log10(double x) log10(x), x>0double sqrt(double x) (x, x(0double fabs(double x) (x(double pow(double x, double y)xydouble ldexp(double x, int n)x*2n10.1.5 ; .double atof(const char *s)atof s double. HUGE_VAL - double-, ; - .int atoi(const char *s)atoi s int. (int)HUGE_VAL - double-, , int; - .void *calloc(size_t nobj, size_t size)calloc , nobj , size. . , - NULL.void *malloc(size_t size)malloc size. . , - NULL.void free(void *p)free , p; p NULL, . p , calloc malloc.10.1.6 : . , , .int setjmp (jmp_buf env)setjmp env longjmp. , setjmp, val ( ), longjmp. setjmp : , if, swith if ( setjmp() = = 0 )/* setjmp */else/* longjmp */void longjmp (jmp_buf env, int val)longjmp , env setjmp. , setjmp val. , longjmp; setjmp . , longjmp, , setjmp, , . 10.2 10.2.1 ::= _ | _ | __ ::= _ | __ ::= | _ ::= _ | __ ::= char| signed char | unsigned char | short | unsigned short | int | unsigned int | long | unsigned long | | __ ::= float | double | long double ::= __ | __ | ____ ::= | | _ ::= _ | _ | _ | void10.2.2 ---------------------------------------------------------------------------------------------------------------- ( ) [ ] ( . ++ - - ( ( ) ! ~ ++ - - + - ( & () sizeof ( ( ) ( / % ( ( ) + ( ( ( ) > ( ( ) < >= ( ( ) == != ( ( ) & ( ( ) ^ ( ( ) | ( ( ) && ( ( ) || ( ( ) ? : ( ( ) = += (= (= /= %= &= ^= |= = ( ( ) , ( ( ) , ., y = *p++; temp = p; p += 1; y = *temp; y = *p; p += 1; , . - , volatile - . ( sequence point ) - , , , - . , , - . , y = 37; x += y; , 37 y , y x + y. , : x , y x y; z ? x : y z x y; ; x && y x || y x y., if ( ( c = getchar() ) != EOF && isprint(c) ) isprint(c) , c . ., val = 10 * val + (c - 0); i = ++i + 2; , , . , f(x) + g(x) , + .10.2.3 X op Y1. short signed char, int; char, unsigned char unsigned short, int, int; - unsigned int. (promoting ).2. .1 , . ( unsigned int - long ) , int, unsigned int, long, unsigned long, float, double, long double. unsigned int long, unsigned int long, long; - unsigned long. (balansing).3. ; - , .10.2.4 M- X N- N < M N == M N>M------------------------------------------------------------------------------------------------------- N-M ------------------------------------------------------------------------------------------------------------- x (0,.. ------------------------------------------------------------------------------------------------------------- |x|