Ps22Pdf

Size: px
Start display at page:

Download "Ps22Pdf"

Transcription

1 ( 98 ) C ( )

2 ( ) C : C C C,,, C,, : C ( ) : : (, ) : : : / 16 :18 25 :415 : : ISBN / T P432 : : 22 00

3 ( 98 ) 20 90,,, ;,,, 1994, 1998, 160, 70,,,,,,,,, : (B) :,, :, QBASIC, FORTRAN, PASCAL, C, FoxBASE : (A) : ; ( B) : :, 1995, B ( ) 8, 120, 1998, : DOS, Windows ; BASIC QBASIC ;,, ( 98 ) : ( 1 ) :, ( 2) :,, (3 ):

4 , , ( 98 )

5 , C C, C C,,, ;, C C,, C,,, 1998 ( C ),, C,, (), C,,,,,, ( ),,,,, C,, ( ) C (, ),, C ( ),,,,,

6 1 C C C C C C C

7 if if if if switch goto while do while while do while while do while for break continue break continue

8

9 main typedef

10 C ( fopen ) ( fclose ) fputc fgetc ( putc getc ) fputs fgets fread fwrite fprintf fscanf rewind fseek ASCII C C C (C ) (C )

11 1 C 1.1 C C, [1.1] C # include < stdio.h > /, / main ( ) / / { int a,b, c ; / / scanf (% d, % d, & a, &b) ; / a b / c = max ( a, b) ; / max, c / printf ( max = % d, c) ; / c / int max (int x, int y)/ max,,x y, / { int z; / max z, / : if (x > y) z = x; else z = y; return (z) ; / x y z / / z, max / (1 ) C main C C, C, C (2 ) C main, main ( main,, ) (3 ) ( printf scanf ), (1.1 max ) (4 ), include, ( 1.1 )7 (5 ) C, 1.1 1

12 , (),, ( Link),, 1.1 C 1 1 C 1.2 : (1 ) 1.1 max :,,, main ( ) (2 ) {, {, 1.1 main int a, b, c max int z, a b c z,, C : c = a + b;, 2

13 1.3 : (1 ), ( 1.1 main max ) (2 ) C,,, (3 ),, if (4 ) / / C, 1.1 A) C B) C main C) C, D) C 1.2 A) B) C) D), 1.3 C A) main B) main C) main D) main 1.4 C A), main B), main C), D) 3

14 1.5 C, : , C , C C C , C, : Very Good 1.14 C, a b c, 4

15 2 2.1 C C : ( ) C, ,, , , a d, : # define PRICE 30 # define PRICE 30, PRICE 30,,,,, ( ),,,, 5

16 2.2.2, (identifier), C,, : sum, average, class, day, month, student - name, - above, lotus , basic : M.D.John, 123, # 33, 3D64, a > b,, sum SUM,, C ( ), ( IBM PC MS C)8, 8, 8,, : student - name student - number, 8,,,, C : (1 ), (2 ), 0, , 83 (3 ), 0x 0x , : int i ; / i / long j, k; / j k / C,, ( word) int, long int, short int Turbo C 2.1 6

17 2.1 Turbo C int (2 15-1) short[int] (2 15-1) long[int] (2 31-1) unsigned[int] unsigned short unsigned long [2.1] { int a, b, c, d; a = 10 ; b = 5 ; c = a + b; d = printf( c = % d \ n, c) ; printf( d = % d\ n, d) ; : c = 15 d = a b c d, a b 10 5, c a b 15d , int, d , : : , (0, 1 ) , 1, ( ),, 7

18 , : (1), ( ) ( 2), 123e3 123E e(e), e, e3 2.1e3.5.e3 e 2., : float a,b; / a b / double c ; / c / Turbo C, Turbo C float double [2.2] { float x ; double y; x = ; y = ; printf( x = % f, y = % f \ n,x, y) ; : x = ,y = , x y, 4 8,,,,,,,,, 8

19 : ( ), a? = ;, \ \ n \ t () \ v \ b \ r \ f \ \ \ \ ( ) \ ( ) \ ddd 1 3 8,\ 123, \ xhh ,\ 21, 16 23,, : char c = \ n ; 2. (), abc \ n a, a,,,, \ 0 ( ASCII 0, ), a, : 3. a \ 0, char : char a,b ; a = O ; b = K ; printf(%c%c \ n, a, b) ; 9

20 OK, : a = O ; b = K ;, a b, O K2 : (1 ), : char c = A ; (2 ), : char c = \ \ ; printf ( % c, c) ; \ (3 ) ASCII, aascii 97( 1), : char c = 97; printf ( % c, c) ; a, ( ASCII ),, aascii 97, : , % c, a ( ASCII ) % d (printf(% d, c) ), 97,, [ 2.3] { int a = A, b; char c = 97; b = c - a ; printf ( % d \ n, b) ; 32, AASCII 65, c - a ,,, ( ) : i, f float, d double, e long, : 10 + a + i f - d/ e 10

21 2.2,,,,, short int, float, ( float, double, ) int double, int double, ( double ), 2 2 double,,, int unsigned, long, double int dou ble, int double, int long, int long : 10 + a, a 97, 107; i f, i f double, double ; 107 i f, 107 ( 0, ), double ; e double, d/ e double ; 10 + a+ i f + d/ e, double C 2.4 C C,, =, C : (1 ) ( + - / % ) (2 ) ( > < = = > = < =! = ) (3 ) (!& & ) (4 ) ( < < > > & ) (5 ) ( = ) (6 ) (? : ) (7 ) (, ) (8 ) ( & ) (9 ) ( sizeof) (10) ( ) (11) (. ) 11

22 (12) ( [ ] ) (13) ( ) (14) ( ( ) ) C C : (1 ), : a = 3 (2 ), : (3 ), :5 > 6 (4 ), :3 > 5 & & a > = b (5 ), : a > b? a : b (6 ), : a = 3, b = 4, c = , : a + b > c & & c + d < e + (c = f) C C,,, a - b c, b,,,, a - ( b c), : a - b + c, C ( ),,, b, a - b, c,, (, ) : a = b = c = 4 c =, c = 4, c 4,,, 4 b a, C, , : + - / % ( ) + + ( )- - ( ) : (1 ), 5/ 2 2,, double 5.0/

23 (2 ) % ( ),, Turbo C, 15 %4 15 % - 4 3, - 15 %4-15% - 4-3, 15.0 % (3 ) , C, (1 ) =, a = 3( ), 3 a (2 ), : a = 5 :,,a = 5 5( a 5 ), : a = (b = 5) b = 5, 5, a = ( b = 5 ) b = 5 a = b, a 5, 5,, (), C C :,,,,, 0 + 5,, : a = a,,, 3 + 5, : = a,, (3 ) =, = + + = : a + = 3 a = a

24 x = y + 8 x = x ( y + 8 ) x% = 3 x = x% 3 a + = 3, a (3 ), a 3, a,x = y + 8x ( y + 8 ), x ( ), C 10, : + =, - =, =,/ =, % =, < < =, > > =, & =,=, = (4 ),, ( ),, i, i = 3.56i 3,,,,, ( signed), ( unsigned),,,, ( ), , , (5 ),, a, b, c long, : a = b + (double)c c long double, b : (),, (6 ), , : + + i, - - i ( i, i ( )1) i + +, i - - ( i,i ( )1 ), + + i i + + i = i i i i i = i + 1, i ; i + + i, i = i + 1 : i = 3 ; printf ( % d, + + i) ; 14

25 4 : printf ( % d, i + + ) ; 3 : ( + + ) ( - - ),,, (a + b) i + +, i,, 3 + +, ( ), - ( i + + ), i 3, printf(%d, - i + + ), i, - i - 3, i 4 (i + + ) i, i 1, 1, - 4, , i 3, : (i + + ) + (i + + ) + (i + + ) , 12 Turbo C MS C 9 i 3, i ; i, 9, i 6 : k = ( + + i) + ( + + i) + ( + + i) i, k = , 15 k = 18, : + + i,, i, i 6, k = , 18 : i 3, : printf ( % d, % d, i, i + + ),, 3,3, printf (i i + + ), i + + i i + +, i 3 i 1 4, 4 printf i printf 4,3, : i + +, i, i 1, [ 2.4] (1 ) x + a% 3 (int) ( x + y) %2/ 4 x = 2.5, a = 7, y = 4.7 (2 ) ( float) (a + b)/ 2 + ( int) x% (int) y a = 2, b = 3, x = 3.5, y = 2.3 : ( 1) (2 )

26 [ 2.5], a = 12 (1 ) a + = a ( 2) a - = 2 (3 ) a = (4 ) a/ = a + a (5 ) a % = ( n% = 2 ), n 5 ( 6) a + = a - = a = a : ( 1) 24 (2 )10 ( 3) 60 (4 )0 (5 )0 (6 ) C, : 3 + 5, 6 + 8, : 1, 2 : 1, 2 2, 3 + 5, , : (a = 3 5, a 4 ), a + 5 a 15, a 4 (a ), a , 20 : 1,2,3,,n n 3,,,,, ( for ),, : printf(% d, % d, % d, a,b, c) ; a, b, c, printf, : printf(% d, % d, % d, (a, b, c),b, c) ; ( a, b, c), c,, 16

27 C 6 : < ( ) < = () > ( ) > = () = =! = : () ( ) () () (1 ) 4 ( <, < =, >, > = ),,> = =, > < (2 ) (3 ) (C ),, : a > b, a + b > b + c, (a = 3) > ( b = 5), a < b, (a > b) > ( b > c) C,,, 0, 1, 0, 1,, 0, 5 = = 30,5 > = 01 a = 3, b = 2, c = 1, : a > b, 1 (a > b) = = c ( a > b 1, c ), 1 b + c < a, 0 : d = a > b d 1 f = a > b > c f 0( >, a > b 1, 17

28 :1 > c, 0, f C : (1 ) & & (AND) (2 ) (OR) (3 )! (NOT) & & (), ( ), ( a > b ) & & ( x > y), ( a > b) ( x > y)! ( ),,! ( a > b) 2 4 : a & &b a b,a & &b a b! a a b,a b a,! a, :! a & &b x > y& & c : (1 )! ( )& & () (),! (2 ) & &,!, , C, 1, 0,, 0, 0,, : (1 ) a = 4,! a 0, a 0,,,, 0 (2) a = 4, b = 5, a& & b 1, a b 0,, a& & b, 1 18

29 ,, :, 5 > 3& &2 8 < 4 -! 0 : 5 > 3 ( & & ), 5 3,5 > 31; 1 & & 2, 1 2,, 1; 1 8 < 4 -! 0,! 0 1,, :1 8 < 4-1, 1 8 < 3, < 8 3,8 < 3 0 ( ) 1 0 1, 0 1, 0 0,, 0 0 : c & & d 1( c dascii 0, ),,, : a& & b & &c a (0 ), b b, a b c c a, b c ( ) a, b, c, 2.5 a b c a (0 ), b c; a, b; a b c, , (), C : 1? 2:

30 2 7 : (1 ) : 1, 0 () 2, (), 3, 3 : max = (a > b)? a :b max, a b max (2 ),, max 2.5 [2.6] x y, : { float x, y, ave ; scanf( % f% f, &x, &y) ; ave = ( x + y)/ 2; printf( ave = % f \ n, ave) ; : 2 5 < > ave = ,, 3 [2.7] , 20

31 : { int r,h ; float v; r = 2 ; h = 4; v = 3.14 r r h ; printf( r = % d, h = % d, v = % f, r, h,v) ; scanf( % d% d, & r, & h) ; v = 3.14 r r h ; printf( r = % d, h = % d, v = % f, r, h,v) ; : r = 2, h = 4,v = < > r = 3, h = 5,v = r h, 3.14,, v C, r 2 r r 2.1 A) ABC L10 a - b - a1 B)? 123 printp a + b C) - 12 Zhangp 11F D) Li - Li P for C, A) B) C) D) 2.3 C A) B) C) 21

32 D) 2.4 C int short char A) 16 (2 ) B) C) D) 2.5 A) ( ) & & ()! () B)! () ( ) & & () C)! ( ) & & () () D) & & ()! ( ) () 2.6 A) b) ( x + y) - - C) + + ( a1 - b2 ) d) ( d + + ) + ( d + + ) + ( d + + ) 2.7 C A) x123 e5 B) x102 13e C) - 0x22d 06f 8e2.3 e D).e7 0xffff 12% 2.5e A) \ n \ \ \ x35 \ B) \ t \ 1010 \ v \ 123 C) \ x110 \ b \ g \ xxx D) \ rr \ r \ 55 \ xff 2.9 A) chr a B) 123 \ C) string S D) 678 \ A) a = 10 + b - - = 9 + k B) (a = 16 9, b + 5), b - 3 C) a = b - - = c - - D) a = b + 7 = a - b 2.11 a 1, a A - 2/ 3 5 3, a = b = c = 6 + 2/ 5 4, 22

33 b = 6, 18 + ( b + = 4 ) a = 3, b = - 4, c = 5,! ( b > c) + ( b! = a) ( a + b) & & ( b - c) a = 3, b = - 4, c = 5, a c + b + + 7, + + a - c + ( + + b) a = 3, b = - 4, c = 5, a + b, b 5, a = b + 4 9, b% = c + a - c/ { int i, j; float a, b; char c; long m,n ; i = 5 ; j = - 3; a = 25.5 ;b = 3.0 ; m = a/ b; n = m + i/ j ; printf(% d \ n,n) ; { char ch; ch = B ; printf(%c, % d \ n, ch, ch) ; 2.18 China, :, AE, E A,China Glmre, c1 c2 c3 c4 c5 China,, c1 c2 c3 c4 c5 G lmr e, Glmr e, 23

34 3 3.1 C C ( ) ( )( ), C : (1 ), C, : if ( )else ( ) for ( ) while ( ) dowhile( ) continue break switch goto return ( ) ( ) ( ) ( ) ( switch ) () ( ) () ( ), :if ( ) else :if( x > y) z = x; else z = y; (2 ), : printf ( This is a C statement. ) ; (3 ) :, : i + + ;, i 1: x + y;, x + y,, x + y, C,,, C ( 24

35 ), C ; (4 ) :,,, (, ) (5 ) {, : { z = x + y; ) t = z/ 100 ; printf(% f, t) ; :, (PASCAL 3.2, C, : (1 ) C =, (2 ) C, : if( (a = b) > 0) t = a ; if a = b, : if ( (a = b; ) > 0) t = a ; if 3.3, C, C, printf scanf, printf scanf,, C, C,, ( printf scanf ),, ( ),, printf scanf 25

36 getchar getchar, : getchar ( ) : (1 ) (2 ), (3 ) getchar,, 2. getche getchar 3. putchar, : putchar (c) ; c, c,, putchar( 97 )a, a ASCII 97putchar ( 10 ) (DOS,, (ASCII 10 ) ) :, ( ) # include < stdio.h > I/ O stdio.h [ 3.1] getchar a b, c1 c2 # include < stdio.h > main ( ) { char c1, c2 ; c1 = getchar( ) ; c2 = getchar( ) ; printf(% c% c \ n, c1, c2 ) ;, ab < >, ab, a < > b < >, c1 a, c2, a, 26

37 [ 3.2] putchar # include < stdio.h > { char c1, c2, c3,c4, c5, c6, c7; c1 = P ; c2 = u ; c3 = t ; c4 = C ; c5 = h ; c6 = a ; c7 = r ; putchar (c1) ; putchar(c2) ; putchar(c3 ) ; putchar(c4) ; putchar (c5) ; putchar(c6) ; putchar(c7 ) ; : PutChar printf printf printf : printf(, ),, : (1 ), %, % d, % f,, % (2 ),, : printf(% d % d, a,b) ; printf( a = % d ] b = % d, a,b) ; % d,, a b 3 4, : a = 3 ] b = 4 ( ] ), printf 3 4 a b ( 3 4 ), a b a b , : a = 12 ] b =

38 : printf,,, printf( 1, 2, 3,, n) printf 2n 1 2., printf d o x u c s f e g ( ) 8 ( 0) 16 ( 0x) 10,, 6,6 % f % e,0, % ( ), l, d o x u f m( ).n(), n ;, - a, 12478; b, , a a b b % d %f % 8d ] ] ] %e e + 03 % o %8.2f ] % x 30be % g % u %10.2e ] ] 1.27e + 03 % - 8d ] ] ] % e 1.27e + 03 ] ] 28

39 : (1 ) C, % e, 3 ( e + 003), 2 ( e + 03 ) 6, 5 (2 ) long ( d o x u ) l, % ld, % lo, % lx, % lu, l, (3 ) %o, % x,,, a = - 2, , % o ( - 2) (4 ) ( int ) %u ;, unsigned %d, unsigned % o % x % u,, a = - 2, %u (5 ) printf \ n \ t \ b \ r \ f \ 377 (6 ) d o x u c s f e g, % %, 9,, : printf( c = % cf = % 10.3fs = %s, c, f, s) ; % c f, %10.3f, s, %s (7 ) %, %, : printf ( % f% %, 1.0/ 3 ) ; % [3.3] # include < stdio.h > { int x1; float x2 ; char c1, c2 ; x1 = 99 ; x2 = 100 ; c1 = a ; c2 = b ; printf( c1 = % c ] c2 = % d ] x1 = % d, x2 = % f, c1, c2, x1, x2 ) ; 29

40 : c1 = a ] c2 = 98 ] x1 = 99, x2 = c1 c2 ab, c2 d, c2 b, ASCII scanf 1. scanf scanf(, ) printf,, [3.4] scanf { int a,b, c ; scanf( % d % d% d, &a, &b, & c) ; printf(% d, % d, % d \ n, a,b, c) ; &a& b& c &, & a a scanf : a b c, a b c % d % d% d% d,, tab : 3 ] ] 4 ] ] ] ] 5 < > 3 < > 4 ] 5 < > 3( Tab )4 < > 5 < > % d%d% d,, : 3,4,5 : 3.4 scanf : scanf( % d, % d, % d, & a, &b, &c)? printf, %,,

41 () 3.4 scanf 3.5 scanf 3.4 scanf d o x c s f e,,, \ 0, f, e f 3.5 scanf l ( %ld, %lo, %lx) double (% lf % le) h ( % hd, % ho, % hx) ( ) ( ) : (1 ) C scanf % u, unsigned, % d %o% x (2 ), : scanf(% 3d% 3d, &a, & b) ; < >, 123 a, 456 b : scanf(% 3c, & ch), ch, abc, ch a (3 ) %, : scanf(% 2d ] % 3d ] % 2d, &a, &b) ; : 12 ] 345 ] 67 < > 12 a, 67 b, 345,, 31

42 (4 ), : scanf(% 7.2f, &a) ;, a < > 3. scanf (1 ) scanf,, a b, : scanf(% d, % d, a,b) ;, a, b& a, & b, C (2 ),, : scanf(% d: % d : % d, &h, & m, & s) ; : < > : scanf( a = % d, b = % d, c = % d, & a, &b, & c) ; : a = 12,b = 24, c = 36 < >, (3 ) % c, : scanf(%c%c%c, &c1, &c2, &c3) ; : a ] b ] c < > a c1, ] c2, b c3, % c,, ] c2 (4 ), :, ( Tab), %3d, 3 : scanf(% d%c% f, &a, &b, & c) ; : 32

43 1234 a 123o.26 < > a b c % d 1234 a, 1234,, 1234 aa b, % c, a, c o.26, 123 o,, 123 c [ 3.5] scanf : a = 13,b = 198, c1 = G,c2 = k,x = 2.38, y = , z = # include < stdio.h > { int a,b; char c1, c2 ; flat x,y, z ; scanf(%3d% 6d%c%c, % f, % f% f% f, & a, % b, % c1, & c2, & x, &y, &z) ; printf(% d, % d, %c, % c, % f, % f, % f \ n, a,b, c1,c2, x, y, z) ; : ] 13 ] ] ] 198 Gk,9.9, < > %3d, 13%6d,, 198 Gk% f, (9.9 )x, y, z : 13,198, G, k,2.38, , [3.6], : # include < stdio.h > { char c1,c2; cl = getchar( ) ; printf(%c, % d \ n, cl, cl) ; c2 = c ; printf(%c, % d \ n, c2, c2 ) ; : A < > A,65 a,97 33

44 [ 3.7] a y, : # include < stdio.h > { char ch; ch = getchar( ) ; putchar (ch) ; : c < > D [ 3.8], (, ) : s = s( s - a) ( s - b) ( s - c) a, b, c, s = a + b + c 2 : # include < math.h > { float a, b, c,s, area ; scanf( % f, % f, % f, & a, &b, & c) ; s = 1.0/ 2 ( a + b + c) ; area = sqrt( s ( s - a) ( s - b) ( s - c) ) ; printf( a = % 7.2f, b = %7.2f, c = % 7.2f, s = % 7.2f \ n, a, b, c, s) ; printf( area = % 7.2f \ n, area) ; : 3,4,6 < > a = 3.00,b = 4.00, c = 6.00, s = 6.50area = : 34 { float y; y = ;

45 printf( % - 8.4f \ n, m) ; printf(%10.4f \ n, m) ; A) B) C) D) int a = - 2; : printf(%8lx, a) ;, A) % d B) % x, C) % x,, %8lx D) %8lx, m n (int ), A) getchar( ) B) scanf(% d% 1d, & m, & n) C) putchar (\ ) D) putchar(\ ) 3.4 getchar getche A) getchar, getche B) getche, getchar C) getchar, getche D) getchar, getchar 3.5, 22 o 98 p, { int x1, x2 ; char c1, c2 ; scanf(% d%c% d%c, &x1, &x2, &c1, &c2) ; printf(% d % c % d % c \ n, x1, x2,c1, c2) ; A) 22 o 98 p < > B) 22o 98p < > C) 22o98 p < > D) 22 o98p < > 3.6 { unsigned int l ; l = 65535; printf(% d \ n, l) ; 35

46 A) - 1 B) C)1 D) 3.7, 25 ] 13 ] 10 < >, { int x,y, z ; scanf(% d% d% d, &x, &y, & z) ; printf( x + y + z = % d \ n, x + y + z) ; A) x + y + z = 48 B) x + y + z = 35 C) x + z = 35 D) 3.8 : scanf( a = %d, b = % d, c = % d, &a, & b, & c), a 3, b 7, c 5, A) 375 < > B) 3, 7, 5 < > C) a = 3, b = 7, c = 5 < > D) a = 3 b = 7 c = 5 < > 3.9 x y float, A) + + x; B) y = ( x%2 ) / 10; C) x = y + 8; D) x = y = 0; 3.10 { long y = ; printf( y = % - 8ld \ n, y) ; printf( y = % - 08ld \ n,y) ; printf( y = % 08ld \ n,y) ; printf( y = % + 8ld \ n, y) ; A) y = B) y = C)y = D) y = y = y = y = y = y = y = y = y = y = y = y = y = , a 4, c , 2 { int a,b;

47 float c, d, e; scanf( a = % d, c = %f, & a, & c) ; printf( a = % d, c = % f \ n, a, c) ; { int a = 3, b = 5; float c = 6.5, d = , e = ; printf( a = % 5d,b = % - 10d, c = %6.2f,d = % 6.2f, e = % f \ n, a,b,c, d, e) ; 3.13, A, 4 # include < stdio.h > { char c; putchar (getchar( ) + 32 ) ; { int i = 100 ; printf(% d, % o, % x, % u \ n, i, i, i, i) ; { int i, j; unsigned int u1, u2; u1 = ;u2 = 40000; i = u1 ; j = u2 ; printf( u1 = % u,u2 = % u \ ni = % d, j = % d \ n, u1, u2, i, j) ; 3.16 % 7, 8 { float f; f = 100.0/ 30; printf(% f% %, f) ;

48 { short n ; n = - 31; printf(\ ndecimal = % d,hex = % x,octal = % o,unsigned = % u \ n,n, n, n, n) ; 3.18 int a; float b, x; char c1, c2; a = 3, b = 6.5, x = 12.6, c1 = a, c2 = A, scanf 10, r = 1.5, h = 3, scanf,, 3.20, :, 2 c = 5 9 ( f - 32 ) 3.21, getchar c1 c2, putchar printf 38

49 4 ( ) if ; switch ; for while do while, continue break 4.1 if if, ( ) if C if : : if( ) : if( x > y) printf ( % d, x) ; if 4.1( a) : if( ) 1 else 2 : if ( x > y) printf ( % d, x) ; else printf (% d, y) ; 4.1( b) :

50 if ( 1) 1 else if( 2) 2 else if( 3) 3 else if ( m) m else m : 4 2 (1 ) if if,, if(a = = b & & x = = y) printf ( a = b, x = y ) ;,, 0,, 0,, if : if (3 ) printf ( O.K. ) ;, O.K., 3,,, ( ), if : if ( a ) printf (% d, a ) ; : a ASCII 97 (2 ) if, else, : 40

51 C, if,,, (if else ), if else, if, if (3 ) if else,, { : if (a + b < c & & b + c > a & & c + a > b) { s = 0.5 (a + b + c) ; else area = sqrt( s (s - a) ( s - b) (s - c) ) ; printf( area = % 6.2f, area) ; printf( it is not a trilateral ) ;, {, {, if if if if, : if ( ) else if ( ) 1 else 2 if if ( ) 3 else 4 if if else if else, if else if if if else : if ( 1 ) if ( 2 ) 1 else if ( 3 ) 2 else if else,, : if ( ) { if ( ) 1 ( if) 41

52 4 3 else 2 { if, else if if [4.1],,, ;, : main ( ) { char ch; scanf (%c, &ch) ; if ( ch > = A& & ch < = Z ) ch = ch + 32 ; printf (%c, ch) ; : A < > a AASCII 65,a ASCII 97 ASCII 32 if if : ch = (ch > = A& & ch < = Z )? (ch + 32) ch; 42 :, if?? [4.2] a b c,

53 # include < stdio.h > : # include < math.h > { int a,b, c, max; scanf (% d, % d, % d, & a, &b, & c) ; max = a ; if ( abs( max ) < abs( b) ) max = b; / max a,b / if ( abs( max ) < abs(c) ) max = c ; / max a, b, c / printf( max = % d \ n, max) ; : 12, - 34,9 < > max = - 34, : # include < stdio.h > # include < math.h > { int a,b, c, temp, max; scanf( % d, % d, % d, & a, & b, & c) ; temp = (abs(a) > abs (b) )? a : b; max = (abs( temp) > abs(c) )? temp: c; printf( max = % dmax) ; 4.2 switch switch, : switch ( ) { case 1 : 1 : case 2 : 2 case n : n default : n + 1 (1 ) case, case 43

54 , case, default (2 ) case, (3 ) case (4 ) case, case case, switch, switch,, case, switch, switch, break (5 ) case, : switch( grade) { case A : case B : case C : printf ( > 60 \ n ) ; break; grade A B C [ 4.3], : 3 5/ < >, { float x,y; char o; double r; scanf(%f %f% c, & x, &y, &o) ; switch(o) { case + : r = x + y; break; case - : r = x - y; break; case : r = x y; break; case / : r = x/ y; break; / / printf(% f, r) ; : [4.4], A B C D E90 A, B, 7079 C,6069 D, 60 E : 44 { int score, temp; char grade ;

55 scanf ( % d, &score) ; if ( score = = 100) temp = 9; else temp = score/ 10; switch( temp) { case 9 : grade = A ;break; case 8 : grade = B ; break; case 7 : grade = C ;break; case 6 : grade = D ; break; case 5 : case 4 : case 3 : case 2 : case 1 : case 0 : grade = E ; printf( score = % d, grade = %c \ n,score, grade) ; : 90 < > score = 90, grade = A [ 4.5], # include < stdio.h > main( ) { int x = 1, y = 0, a = 0, b = 0; switch( x) { case 1 : / / switch( y) { case 0 : a + + ; break; /, switch / case 1 : b + + ; break ; case 2 : a + + ; b + + ; break; / switch, / printf( a = % d, b = % d, a, b) ; : a = 2, b = 1 switch : break switch 45

56 4.3 goto goto, : goto ;,,, goto, goto, goto, : (1 ) if ( 2), C break continue goto, goto,, ( ) 10 0 [4.6] if goto, n n = 1 : { int i,sum = 0 ; i = 1; loop: if ( i < = 100) { sum = sum + i ; i + + ; goto loop; printf(% d, sum) ; : while 4.4 while do while while, : while( ) 46

57 0, 4.4 :, : (1 ),,, while while (2 ), do while, : do while( ) ; 4 4 :, :,, ( ),,, 0,, while do while while, do while do while while do while while 4.4, ( ), while do while,, while while ( 0 ), 10 [4.7] while do while n n = i (1) ( 2) { int sum = 0, i ; { int sum = 0, i ; scanf (% d, & i) ; scanf(% d, & i) ; while(i < = 10) { sum = sum + i ; { sum = sum + i ; do i + + ; i + + ; while(i < = 10 ) ; printf( % d, sum) ; printf( % d,sum) ; 47

58 i 10, i > 10,, while, ( i < = 10), do while : while,, ( ) : do while,,,, until ( FORTRAN DO U N TIL), do while,, until() 4.5 for C for,,, while for for( 1; 2;3) : (1 ) 1 (2 ) 2, (0 ),, (3 ) (0 ),, ( 5) (3 ),, 3 (4 ) ( 2) (5 ) for 4.7 for for : for(; ; ) : for (i = 1 ; i < = 100 ; i + + ) sum = sum + i : i = 1 ; while (i < = 100 ) { sum = sum + i ; i + + ; 4 7, for for : 1 ; 48

59 while( 2) { for 3; : ( 1) for 1, for 1, : for ( ; i < = 100; i + + ) sum = sum + i ;, 1, (2 ) 2,, 2 4.8: for (i = 1 ; ; i + + ) sum = sum + i ; : i = 1 ; while (1 ) { sum = sum + i ; i + + ; 4 8 (3 ) 3, : for ( sum = 0, i = 1; i < = 100 ; ) { sum = sum + i ; i + + ; i + + for 3,,, (4 ) 1 3, 2, : for ( ; i < = 100 ; ) while (i < = 100) { sum = sum + i ; : { sum = sum + i ; i + + ; i + + ;, while for while,,, (5 ), : for ( ; ; ) 49

60 while (1 ), ( 2 ), (6 ) 1, : for (sum = 0; i < = 100 ; i + + ) sum = sum + i ; 3 1 3,,, : for ( sum = 0, i = 1; i < = 100; i + + ) sum = sum + i; for (i = 0, j = 100 ; i < = j; i + +, j ) k = i + j ; 1 3,,,, ,, for (i = 1 ; j < = 100; i + +, i + + ) sum = sum + i; for (i = 1 ; i < = 100; i = i + 2) sum = sum + i ; (7 ) 2 ( i < = 100 ) ( a < b & & x < y),,, : for (i = 0 ; (c = getchar ( ) )! = \ n ; i + = c) ; 50 2 c,

61 \ n (), \ n, for 4.10,, ASCII, : for, 3, for, break 4.6 break continue break switch,,, : break; break switch [4.8] { int i,s = 0 ; for(i = 1; i < = 10 ; i + + ) / i > 10 / { s + = i; : s = 1 s = 3 if(s > 5) break ; / s > 5 / printf( s = % d \ n,s ) ; : switch break, continue : continue;,, [4.9] { int i,n,s ; s = n = 0; 51

62 for(i = 1; i < = 10 ; i + + ) {if(i% 2 = = 0 ) { s + = i; continue ; / i, n + + ; / n + + ; printf( s = % d, n = % d \ n, s, n) ; : s = 30, n = 5 continue break : continue, break, : ( 1) while( 1) (2 ) while(1) { { if ( 2) break; if (2) continue ; (1 ) 4.11, ( 2) ,, 52

63 : (while do while for ), ( 1) while ( ) ( 2) do (3 ) for ( ; ; ) { { { while ( ) do for ( ; ; ) { { {..... while ( ) ; while ( ) ; ( 4) while ( ) ( 5) for ( ; ; ) ( 6) do { { { do while ( ) for ( ; ; ) { { { while( ) ; while ( ) ; 4.8 [ 4.10], 3 4, 3 4, 3 4 : { int number; printf( : ) ; scanf(% d, & number) ; if ( number %3 = = 0 & & number %4 = = 0 ) else printf( 3 4! printf( 3 4! \ n ) ; \ n ) ; : :13 < > 3 4! : :24 < > 3 4! [4.11] : 53

64 y = ( x < 0) ( x = 0) ( x > 0), x, y : { int x, y; scanf(% d, &x) ; if ( x < 0 ) y = - 1 ; else if( x = = 0) y = 0; else y = 1 ; : 3 < > printf( x % d, y % d, x, y) ; x 3,y 1 [ 4.12] year, : year 4, 100, ; year 400, ;, : # include < stdio.h > { int year, leap; : printf( Enter a year: \ n ) ; scanf( % d, &year) ; if(year %4! = 0 ) leap = 0; else if( year% 100! = 0) leap = 1 ; else if( year% 400 = = 0) leap = 1; else leap = 0 ; Enter a year: 37 < > if( leap! = 0 ) printf( % d is a leap year. \ n, year) ; else printf(% d is not a leap year. \ n, year) ; 37 is not a leap year. 54

65 ,, [ 4.13] ax 2 + bx + c = 0, : x1 = - b + b2-4 ac 2 a : b 2, x2 = - b - b2-4 ac, (, a 0) 2 a - 4 ac > 0, x1 x2 ; b 2 b 2-4 ac = 0, x1 x2 ; - 4 ac < 0,, : # include < stdio.h > # include < math.h > { float a, b, c,d, p, r,x1, x2; scanf(%f %f% f, & a, &b, &c) ; d = b b - 4 a c; p = - b/ (2 a) ; if( d > = 0) { r = sqrt( d)/ (2 a) ; x1 = p + r; x2 = p - r; printf( x1 = % f, x2 = % f \ n, x1, x2) ; else printf( \ n ) ; : : < > x1 = , x2 = : < > x1 = , x2 = : < > [4.14] , 55

66 10-6 : # include < math.h > { int s; float n, t, pi ; t = 1 ; pi = 0; n = 1.0; s = 1 ; while( (fabs( t) ) > = 1e - 6 ) { pi = pi + t ; n = n + 2 ; s = - s ; / / t = s/ n ; / t / / pi / 4 / pi = pi 4; printf( pi = % 10.6f \ n,pi) ; : pi = [ 4.15] 1!+ 2!+ 3!+ 4!+ + 20! : { float n,s, t ; n = 1 ; s = 0; t = 1; do { t = t n; s = s + t ; n + + ; while( n < = 20) ; printf( 1! + 2! ! = %e \ n,s) ; : 1!+ 2! != e + 18 [4.16], 1.20,,, 100, : # include < stdio.h > 56

67 { int t = 0, m ; float z = 0.0,pj ; for (m = 2; m < = 100 ; ) { z + = 1.20 m ; t + + ; m = 2 pj = z/ t ; printf(% f, pj) ; : [ 4.17],, : # include < stdio.h > { int i ; char number; for ( i = 1; ; i + + ) { scanf(%c, &number) ; if (number = = ) else break; printf( % c,number) ; printf( ) ; : ABC < > ABC for for ( i = 1; ; i + + ), 2 ( ),, if,, [4.18] : { int n; 57

68 for ( n = 100 ;n < 120 ;n + + ) { if (n %3 = = 0 ) continue ; : printf(% d,n) ; n 3, continue,, printf, n 3, printf, [ 4.19], : # include < stdio.h > { char c ; int letter = 0, space = 0,digit = 0, other = 0 ; while ( (c = getchar( ) )! = \ n ) { if(c > = a& & c < = zc > = A& & c < = Z ) let ter + + ; else if(c = = ) space + + ; else if (c > = 0& & c < = 9 ) digit + + ; else other + + ; printf( letter = % d,space = % d,digit = % d,other = % d \ n, letter, space, digit,other) ; : He is 46 years old.< > letter = 12, space = 4, digit = 2,other = 1 58 [4.20]

69 : { int i, j, k; for ( i = 0; i < = 3; i + + ) { for (j = 0 ; j < = 2 - i ; j + + ) printf( ) ; for ( k = 0; k < = 2 i ;k + + ) printf( ) ; printf(\ n ) ; for ( i = 0; i < = 2 ; i + + ) { for (j = 0 ; j < = i; j + + ) printf ( ) ; for ( k = 0; k < = 4-2 i ; k + + ) printf( ) ; printf ( \ n ) ; [ 4.21],,,153, 153 = : { int i, j, k, n; for ( n = 100 ; n < 1000; n + + ) /, n / { i = n/ 100; / / j = n/ 10 - i 10 ; / / k = n% 10 ; / / if(i j 10 + k = = i i i + j j j + k k k) printf(%5d,n) ; printf(\ n ) ; : [4.22] m n, : { int a,b, num1, num2, temp; scanf(% d% d, &num1, &num2) ; if( num1 < num2) { temp = num1; num1 = num2; num2 = temp; a = num1; b = num2 ; / if a b / 59

70 while( b! = 0 ) { temp = a% b; a = b; b = temp; / / printf(: % d \ n, a) ; printf(: % d \ n,num1 num2/ a) ; : 12 8 < > :4 :24 [ 4.23], m, m 1 1, m, 2 3 m - 1 m, m, m, m, m, m 2 3, [ m ][ m ] m i > k, 2[ m ],, : # include < stdio.h > # include < math.h > { int i, m, k; printf( Enter m : \ n ) ; scanf(% d, &m) ; k = ( int) sqrt( ( float) m) ; / k = sqrt(m) ; / i = 2 ; while( i < = k & & m% i! = 0) i + + ; / i < k, / if(i > k) printf( % d is a prime number. \ n, m) ; else printf(% d is not a prime number., m) ; : Enter m : < > 17 is a prime number. Enter m : 18 < >

71 18 is not a prime number. [ 4.24] : # include < math.h > main ( ) { int m, k, i,n = 0 ; for (m = 101 ; m < = 200; m = m + 2 ) { if ( n% 10 = = 0) printf(\ n ) ; : k = sqrt(m) ; for (i = 2; i < = k; i + + ) if ( m%i = = 0) break; if (i > = k + 1 ) { printf(% d, m) ; n = n + 1; , [4.23], for break, [4.23] 4.1 A) 0 1 B) 0 0 C) D) 4.2 char ch A) A < = ch < = ZB) (ch > = A ) & (ch < = Z ) C) ( ch > = A ) & & ( ch < = Z ) D) ( A< = ch) AND ( Z> = ch) 4.3 if A) if ( a1 = = b1 & & c1 = = d1 ) printf( ) ; B) if ( 97 ) printf( ) ; C) if (cx! = cy) {cx - - ; cy + + ; 61

72 D) if (a > b) printf( % d, &a) else printf(%d, & b) ; 4.4 if, else A) if B) if C) if D) if 4.5 if A) if( a > b ) ; printf(% d %d, a, b) ; else printf(%d % d, a, b) ; B) if(a > b) temp = a; a = b; b = temp; printf(%d % d, a, b) ; else printf(% d % d, a, b) ; C) if( a > b ) { temp = a ; a = b; b = temp; printf(% d %d, a, b) ; ; else printf(% d % d, a, b) ; D) if(a > b) { temp = a; a = b; b = temp; printf(% d % d, a, b) ; else printf(%d % d, a, b) ; 4.6 x1 > x2? x1 : ( x3 > x4? x3: x4 ) x1 = 1, x2 = 3, x3 = 5, x4 = 7 A) 1 B) 3 C) 5 D) { int x = 2,y = - 1,z = 2; if ( x < y) if (y < 0) z = 0 ; else z + = 1; printf( % d \ n, z) ; A) 3 B) 2 C) 1 D) # include stdio.h { int a,b, d = 241 ;

73 a = d/ 100 % 9; b = ( - 1) & & ( - 1 ) ; printf( % d, % d, a, b) ; A) 6,1 B) 2,1 C) 6, 0 D) 2, switch A) case B) case C) default D) break 4.10 class 3, switch ( class) { case 1: printf( First! \ n ) case 2: printf( Second! \ n ) ; case 3: printf( Third! \ n ) ;break; case 4: printf( Fourth \ n ) ; default : printf( Error! \ n ) ; A) Third B) Third Error Four th Error C) Third D) Error 4.11 x = 3; do { y = x - - ; if (! y) { printf( ) ; continue ; printf( # ) ; while(1 < = x < = 2) ; A) # # B) # # C) D) 4.12 while(! a)! a { int a ; scanf( % d, & a) ; while(! a) { printf(o.k. \ n ) ; 63

74 a =! a ; A) a = = 0 B) a! = 1 C) a! = 0 D) a = = for ( n = 100 ; n < = 200 ; n + + ) { if( n% 3 = = 0) continue ; printf (%4d,n) ; A) for( n = 100 ; ( n% 3) & & n < = 200; n + + ) printf(%4d, n) ; B) for( n = 100; ( n%3 ) n < = 200; n + + ) printf(%4d, n) ; C) for( n = 100 ; n < = 200; n + + ) if( n% 3! = 0 ) printf(% 4d, n ) ; D) for( n = 100; n < = 200; n + + ) { if( n%3 ) printf(% 4d, n ) ; else con tinue; break; 4.14 C, year, leap year, : 4, 100 ; 4, 400 () { int year; scanf(% d, &year) ; if( (year % 4 = = printf( leap year ) ; 2 year % 100! = 0) 3 year % 400 = = 0) 4.16 Fibonacci :1,1,2,3,5,8, 40, : F1 = 1 ( n = 1 ) F2 = 1 ( n = 2 ) F = Fn Fn - 2 ( n 3) 4 64 { long int f1 = 1, f2 = 1; int i ;

75 for (i = 1 ; 4 ; i + + ) { printf( % 12ld% 12ld, f1, f2) ; if( 5 ) printf( \ n ) ; f1 = f1 + f2 ; f2 = 6 ; { int i; for (i = 1; i < 6; i + + ) { if (i % 2) printf( ) ; else continue ; printf(& ) ; < >, 8 # include < stdio.h > { int c ; while( (c = getchar( ) )! = \ n ) switch(c - 2 ) { case 0 : case 1 : putchar(c + 4 ) ; case 2 : putchar(c + 4 ) ; break ; case 3 : putchar(c + 3 ) ; case 4 : putchar(c + 2 ) ; break ; printf(\ n ) ; { int k = 1 ; while( k < = 20) if( + + k% 4! = 2) continue; else printf( % d, k) ; printf(\ n ) ;

76 { int x = 1, y = 3, z = 5 ; switch( x = = 1) { case 1 : switch (y < 0) { case 1 : printf( A ) ;break; case 2 : printf( B ) ;break; case 0 : switch (z = = 2 x + y) { case 0: printf( C ) ; break; default : printf( F ) ; printf(\ n ) ; case 1: printf( D ) ;break ; default :printf( E ) ;break; { int a,b ; ; for (a = 0,b = 10; a < b; a + = 2) b = b - 1 ; printf( a = % d, b = % d \ n, a, b) ; { int x1 = 10, x2 = 5,x3 = 5, x4 = 5 ; int l = 0, m = 0,n = 0 ; for ( ;x1 > x2 ; + + x2 ) l + + ; while(x1 > + + x3 ) m + + ; do n + + ; while( x1 > x4 + + ) ; printf( l = % d, m = % d,n = % d \ n, l, m, n) ; 4.23, 13 ( ), 14 y = ( x < 0 ) ( x = 0 ) ( x > 0 ) 66 { int x,y; ( 1) scanf(% d, & x) ;

77 ( 2) y = 0; ( 3) if ( x > = 0 ) ( 4) if ( x > 0 ) y = 1 ; ( 5) else y = - 1 ; ( 6) printf( x = % d, y = % d \ n,x,y) ; 4.24 ( I) 10, 10% ; 10, 20 ( < I200000), 10 10%, 10, 7.5 % ; < I400000, 20 ( ), 20 5 % ; < I600000, 40 3 % ; < I , % ; I > , 100 1% I, : if ; switch 4.25,, 4.26,,, ;,,,, 4.27,, , 6 = , , 6 its factors are 1,2, : 10 0 k = 1 50 k + k 2 k = k = 1 1 k 67

78 : [] ; : int a[10] ; a, 10 : 5.1 [] [] ; : float a[3] [4 ], b[5] [10 ] ; a 34 (3 4 ), b 510 (5 10 ) : float a[3,4],b[ 5,10] ; : (1 ), (2 ),, : int a (10 ) ; (3 ), : int n = 5 ; # define M 5 int a[ n] ; () int a[ M ] ; ( ) (4 ),, int a[10] ; a 10, 0, 10 : a[0 ], a[ 1], a[2 ], a[ 3], a[ 4], a[5 ], a[ 6], a[7 ], a [8 ], a[ 9] int a[3 ] [ 4] ; a 3 4, 0 12 : a[ 0] [0 ], a[0 ] [ 1 ], a[ 0 ] [2 ], a[ 0 ] [ 3], a[ 1 ] [ 0], a [1 ] [ 1 ], a [ 1] [ 2 ], a [ 1] 68

79 [3 ], a[ 2] [0 ], a[ 2] [1 ], a[ 2] [2 ], a[ 2] [3 ] (5 ) :,, 5.1 a[3 ] [ 4] 5 1 (6 ) C,, : float a[2] [3 ] [4 ] ; :, (1 ) : int a[10] = {0, 1,2,3,4,5,6,7,8,9 ;, a[ 0 ] = 0, a[ 1 ] = 1, a[ 2 ] = 2, a[ 3 ] = 3, a[ 4 ] = 4, a[ 5] = 5, a[ 6] = 6, a[ 7] = 7, a[ 8] = 8, a[ 9] = 9, : int a[ ] = {0,1,2, 3,4,5,6,7, 8,9;, 10, a 10 (2 ) : int a[10] = {0, 1,2,3,4 ; a 10, 5, 5 0, 1, 2, 3, 4, 5 0,, 10 : int a[ ] = {0,1,2,3,4 ; a 5, 10 (3 ) 0, : 69

80 int a[10] = {0, 0,0,0,0,0,0,0,0,0 ; int a[ 10 ] = {0;,, static(, ), 0: int a[ 10] ; static int b[ 10 ] ; a[ 0] a[ 9], b [0 ] b [9 ]0 2. (1 ) : int a[ 3] [ 4] = {{1,2,3, 4, {5,6,7, 8, {9,10,11,12 ;,, (2 ), : int a[ 3] [ 4] = {1, 2,3,4,5,6, 7,8,9,10,11,12 ;,,,,, (3 ), : int a[ 3] [ 4] = {{1, {5, {9 ; 1, 0 : : int a[ 3] [ 4] = {{1, {0, 6, {0,0,11; : : int a[ 3] [ 4] = {{1, {5, 6 ; :

81 (4 ) ( ),, : int a[ 3] [ 4] = {1, 2,3,4,5,6, 7,8,9,10,11,12 ; : int a[ ] [ 4] = {1, 2,3,4,5,6,7,8,9,10,11,12 ;, 12, 4, 3, : int a[ ] [ 4] = {{0,0,3, {, {0, 10;, : 3 : , C : [] : [] [] a[ 2] [3 ] a[ 2-1 ] [ 2 2-1] : a[2, 3], a[ 2-1, ],, : b[ 1] [2] = a[ 2] [ 3]/ 2, : int a[3 ] [4 ] ; ( ) a[3] [4 ] = 3; ( ) a 34, 02, 03 a[ 3] [4 ] a [ 3 ] [ 4 ] a [ 3 ] [ 4 ] a[ 3] [4 ], a [ 3 ] [ 4 ] 3 4, a[ 3] [4 ] 71

82 5.2,, [ 5.1] 10, : (1 ) 10, 10 ; (2 ) ; (3 ) ; (4 ) (, ) : { int i, j, t, a[ 10] ; for( i = 0; i < 10 ; i + + ) scanf(% d, &a[i] ) ; for( i = 0; i < 10 ; i + + ) printf(% 4d, a[ i] ) ; printf( \ n ) ; for( i = 9; i > = 0; i - printf( \ n ) ; for(i = 0, j = 9 ; i < j; ) - ) printf( % 4d, a[i] ) ; { t = a[i] ; a[i] = a[j] ; a[j] = t ; i + + ; j - - ; for( i = 0; i < 10 ; i + + ) printf(% 4d, a[ i] ) ; printf( \ n ) ; : < > ,, : a[0 ] a[ 9 ], a[1 ] a[ 8 ],, i < j [5.2] 10,, : 72 { int i, j, t, a[10 ] = {2,4,1,6,5,9,7,0, 8,3; for(i = 0; i < 10 ; i + + ) printf(% 4d, a[i] ) ; printf(\ ninput t : \ n ) ;

83 scanf( % d, & t) ; for(i = 0; i < 10 ; i + + ) if( t = = a[i] ) break; for(j = i ; j < 9; j + + ) a[j] = a[j + 1] ; for(i = 0; i < 9; i + + ) printf(%4d, a[i] ) ; printf(\ n ) ; : Input t : 1 < > ,,, break,, 0, 7,, a[ 8] a[ 7], a[ 9] a[8 ] 3,, 9 [ 5.3], k,, k = 0, a[ k ] a[ 1], a[1 ] a [ k ], k = 1, k,, k a[0 ] a[ 1], a[ k ] a[2 ], a[2 ] a[ k ], k = 2, k, k a[0 ]a[ 2],, k a[0 ]a[ 9 ] for, a[ 0 ] a[ k], : # define M 10 { int i, j, a[ M ], k, t ; for(i = 0; i < M; i + + ) scanf(% d, &a[i] ) ; for(i = 0; i < M; i + + ) printf(% 4d, a[i] ) ; printf(\ n ) ; k = 0 ; for(j = k + 1 ; j < M ; j + + ) if(a[j] < a[ k] ) k = j ; t = a[0] ; a[0 ] = a[ k] ; a[ k] = t ; for(i = 0; i < M; i + + ) printf(% 4d, a[i] ) ; printf(\ n ) ; : 73

84 < > [ 5.4] , k 0, a[ 0]a[9 ] 0,, k i(0i8),, a[i] a[ 9 ] i, i 0 8, i for : main ( ) { int i, j, k, temp, a[10] ; for (i = 0 ; i < 10; i + + ) scanf(% d, &a[i] ) ; for ( i = 0; i < 9 ; i + + ) { k = i ; for (j = k + 1; j < 10 ; j + + ) if(a[j] < a[ k] ) k = j ; temp = a[i] ; a[i] = a[k ] ; a[ k] = temp; for (i = 0 ; i < 10; i + + ) printf(% d, a[i] ) ; printf(\ n ) ; : < > [5.5] 10 ( ) :,, , 2 3 ( 9 5) 5, , : 9,, 0 ( 5 ),, 5, 5. 34, 8, 6 5, 5, n, n - 1 j n - j n = 10, 11, a[ 0], a[ 1] a[ 10 ], 74

85 { int a[11 ] ; int i, j, t ; printf( input 10 numbers: \ n ) ; for ( i = 1; i < 11 ; i + + ) scanf(% d, & a[ i] ) ; printf(\ n ) ; for ( j = 1; j < = 9 ; j + + ) for (i = 1 ; i < = 10 - j ; i + + ) if(a[i] > a[i + 1] ) {t = a[i] ; a[i] = a[i + 1 ] ; a[i + 1] = t ; printf( the sorted numbers : \ n ) ; for ( i = 1; i < 11 ; i + + ) : printf( % d, a[i] ) ; input 10 numbers : 75

86 < > the sor ted numbers: [ 5.6] a 10, a, : { int i, j, x, a[11] = {1,3,5,7,9,11, 13,15,17,19 ; / / printf( Input x : \ n ) ; scanf(% d, &x) ; for( i = 0 ; i < 10; i + + ) printf( % 4d, a[i] ) ; / / printf(\ n ) ; i = 0 ; / / while( i < 10 & & a[i] < x ) i + + ; / / for( j = 9 ; j > = i ; j - - ) a[j + 1] = a[j] ; / / a[i] = x; / x / for(i = 0; i < 11 ; i + + ) printf(% 4d, a[i] ) ; / / printf(\ n ) ; : Input x: 4 < > [5.7] : : 76 { int a[2] [3 ] = {{1,2,3, {4, 5,6 ; int b[ 2] [3], i, j; printf( array a : \ n ) ; for (i = 0 ; i < 2 ; i + + ) { for (j = 0; j < 3 ;j + + ) { printf( % 4d, a[i] [j] ) ; b[i] [2 - j] = a[i] [j] ; printf(\ n ) ; a = b =

87 printf( array b: \ n ) ; for(i = 0; i < 2; i + + ) { for (j = 0 ; j < 3 ; j + + ) printf(% 4d,b[ i] [ j] ) ; printf( \ n ) ; : array a : array b: [ 5.8] : (1 ) 1; (2 ),, : { int i, j, yh[ 6] [ 6] ; for ( i = 0; i < 6 ; i + + ) { yh[i] [0 ] = 1 ; yh[i] [i] = 1; / 1 / for ( i = 2; i < 6 ; i + + ) for (j = 1 ; j < i ; j + + ) yh[i] [j] = yh[i - 1] [j - 1] + yh [i - 1] [j] ; / / for ( i = 0; i < 6 ; i + + ) { for( j = 0; j < = i; j + + ) printf(% 4d, yh[ i] [ j] ) ; printf(\ n ) ; 77

88 [ 5.9], 36 5,, : # include < stdio.h > { float a[ 3] [ 6],x,sum ; int i, j; for ( i = 0; i < 3 ; i + + ) for(j = 0 ; j < 5 ; j + + ) { scanf(% f, & x) ; a[i] [j] = x; for (i = 0 ; i < 3; i + + ) { sum = 0 ; for (j = 0; j < 5; j + + ) sum = sum + a[i] [j] ; a[i] [5 ] = sum/ 5 ; for(i = 0 ; i < 3 ; i + + ) { for (j = 0; j < 6 ; j + + ) : printf( % 5.1f, a[i] [j] ) ; printf(\ n ) ; < > < > < > , ( ), ( )sum = 0,,, [5.10] 34,, : 78

89 { int i, j, row = 0, colum = 0, max; int a[3] [4 ] = {{1,2,3,4, {9,8,7,6, { - 10, 10, - 5,2 ; max = a[0 ] [ 0] ; for ( i = 0; i < = 2; i + + ) for (j = 0 ; j < = 3 ; j + + ) if ( max < a[i] [j] ) { max = a[i] [j] ; row = i; colum = j ; printf( max = % d, row = % d, colum = % d \ n, max, row, colum) ; : max = 10, row = 2, colum = 1 row colum max, max a[ 0] [0 ], a[0 ] [0 ], row colum 0, max, max row colum, , : char c[ 10 ] ; c, 10 : c[ 0] = I ; c[ 1] = ; c[2 ] = a ; c[3] = m ; c[4] = ; c[ 5] = h ; c[6 ] = a ; c[ 7] = p ; c[8 ] = p ; c[ 9] = y ; 5.4 c[ 0] c[1 ] c[2] c[ 3] c[ 4] c[5 ] c[6] c[ 7] c[ 8] c[9 ] I a m h a p p y 5.4, : int c[10] ; 79

90 5.3.2, : (1 ), : char c[ 10 ] = { I, a, m, h, a, p, p, y ; (),,, ( ASCII 0),, : char c[ ] = { I, a, m, h, a, p, p, y ; c 10, : char diamond[5] [5] = {{,,, {,,,, {,,,,, {,,,, {,, ;, 5.5 (2 ) : char c[ ] = { I am happy ;, : char c[ ] = I am happy ;, \ 0, 5 5 char c[ ] = { I, a, m, h, a, p, p, y,\ 0 ; 5.3.3, \ 0\ 0 ASCII 0,, % c \ 0, Hello, 6, : ASCII : H e l l o \ 0 80

91 , : : (1 ) % c (2 ) % s, ( string ) char c[ ] = China ; printf(% s, c) ; c 5.6, \ 0 : China : \ 0 C h i n a \ % s, printf, : printf ( % s, c[ 0] ) ;, \ 0: char c[ 10 ] = { China ; printf ( % s, c) ; China, 10 \ 0, \ 0 : (1 ) % c: scanf (% c% c% c, & c[1 ], &c[2 ], &c[3] ) ; 3 (2 ) %s : scanf (% s, c) ; scanf c,, : 81

92 char c[ 6] ; : China < > \ 0, 6 scanf, : char str1[ 5],str2 [5], str3[5 ] ; scanf (% s % s% s, str1, str2, str3) ; : How are you? str1 str2 str3 5.7 str1 : str2 : str3 : H o w \ 0 \ 0 a r e \ 0 \ 0 y o u? \ \ 0 : char str[13] ; scanf (% s, str ) ; 12 : How are you? 12 \ 0 str, How str, How, \ 0, \ 0str 5.8 & H o w \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ : scanf, 5.3.5,, : # include < string.h > 1. puts( ) 82 (\ 0 ) puts

93 char str[ ] = China \ nbeijing ; puts ( str) ; : China Beijing, 2. gets( ) :,, : gets ( str) : puts gets, : puts ( str1, str2 ) gets( str1, str2 ) 3. strcat( 1, 2), 2 1, 1, 1 ( 8 ) char str1[ 30] = People s Republic of ; : char str2[ ] = China ; printf ( % s, strcat(str1, str2) ) ; People s Republic of China : (1 ) 1, (2 ) \ 0, 1 \ 0, \ 0 4. strcpy( 1, 2), 2 1 : (1 ) 1, 1 2 (2 ) 1(str1 ), 2 83

94 :,, char str1[ 20] ; char str2[ 20] = China ; strcpy( str1, str2) ; strcpy ( str1, China ) ; (3 ) \ 0 1 (4 ) : str1 = China ; str1 = str2 ; strcpy : char c ; c = a ; 5. strcmp( 1,2) 1 2: strcmp ( str1,str2 ) ; strcmp ( China, Korea ) ; strcmp ( str1, Beijing ) ;, ( ASCII ), \ 0, ;, 1 2, 0 1 2, 1 2, :, : if ( str1 = = str2 ) printf ( yes ) ; : if ( strcmp ( str1,str2 ) = = 0) printf ( yes ) ; 6. strlen( ), \ 0: char str[10] = China ; 84

95 printf ( % d,strlen( str) ) ; 10, 6, 5, : strlen ( China ) 7. strlwr( ) lwr lowercase ( ) strlwr( ABC )abc 8. strupr( ) upr uppercase ( ) strupr( abc ) ABC, : C, ( ),, [5.11] : # include < stdio.h > # include < string.h > { int i, j ; char t, ch[ 80] ; gets(ch) ; puts(ch) ; for (i = 0, j = strlen(ch) - 1 ; i < j ; i + +, j - - ) / j / { t = ch[i] ; ch[i] = ch [j] ; ch[j] = t ; puts(ch) ; : asdfgh < > asdfgh hgfdsa [5.12], strlen : 85

96 # include < stdio.h > { int i = 0 ; char a[ 80 ] ; gets(a) ; puts( a) ; while( a[i]! = \ 0 ) i + + ; /, i 1 / printf(% d \ n, i) ; : asdfgh < > asdfgh 6 [ 5.13], strcat : # include < stdio.h > { char s1 [80 ], s2 [40 ] ; int i = 0,j = 0; printf( \ n Input string1: ) ; scanf(% s, s1) ; printf( \ n Input string2: ) ; scanf(% s, s2) ; while( s1[ i]! = \ 0 ) i + + ; / i 1, / while( s2[ j]! = \ 0 ) s1 [i + + ] = s2[ j + + ] ; / / s1[ i] = \ 0 ; / / printf( \ n New string: % s, s1) ; : Input string1 : country < > Input string2 : side < > New string: country side [5.14], from to strcpy,\ 0 \ 0 : # include < string.h > 86

97 # include < stdio.h > { char from[80], to[80] ; int i; : printf( Input string: ) ; scanf(% s, from) ; for (i = 0; i < = strlen( from) ; i + + ) / i / to[i] = from[i] ; /, \ 0/ printf( Copied string: % s \ n, to) ; Input string: student < > Copied string: student [ 5.15], s1 s2 strcmp : # include < stdio.h > { int i = 0, a; : char s1 [80 ], s2 [80 ] ; gets( s1) ; gets (s2 ) ; puts( s1 ) ; puts( s2 ) ; while ( s1 [i] = = s2[i] & & s1[i]! = \ 0 ) i + + ; / s1[i]! = \ 0s2 [i]! = \ 0/ a = s1 [i] - s2 [i] ; boy < > if(a > 0 ) printf( ( s1 : % s) > ( s2: % s) \ n, s1,s2) ; if(a = = 0 ) printf( ( s1 : % s) = ( s2: % s) \ n, s1,s2 ) ; if(a < 0 ) printf( ( s1 : % s) < ( s2: % s) \ n, s1,s2) ; girl < > boy girl ( s1 :boy) < ( s2 :girl) [5.16],, : # include < stdio.h > { int i,num, word; 87

98 char str[ 80 ] ; gets( str) ; num = 0 ; / num, 0 / word = 0; /, / for ( i = 0; str[ i]! = \ 0 ; i + + ) if(str[ i] = = ) word = 0; /,, / else if( word = = 0 ) /, / { num + + ; / word 0, 1 / word = 1 ; / word = 1 / printf( words: % d \ n, num) ; : I am a boy.< > words :4 [ 5.17], : # include < stdio.h > # include < string.h > { int i ; char max[20],str[ 5] [ 20 ] ; / / gets( str[0 ] ) ; /, str[i]i + 1 / strcpy(max, str[0 ] ) ; / max, max / for(i = 1; i < 5; i + + ) { gets (str[ i] ) ; if( strcmp(max, str[i] ) < 0 ) strcpy(max, str [i] ) ; printf( The largest string is \ n% s \ n, max) ; : from < > 88 goto < > get < > girl < > first < > The largest string is goto,

99 , strcmp strcpy, str[i], 5.1 A) B) C) D) C, A) int a(5 ) = {1, 2, 3, 4, 5; B) int a[ 5] = {1, 2, 3, 4, 5; C) int a[5 ] = {1-5; D) int a[ 5] = {0,1,2,3,4,5; 5.3 : char x[ ] = ; char y[ ] = { 1, 2, 3, 4, 5 ; A) x y B) x y C) x y D) 5.4 A) int s[2 ] [ ] = {{2,1,2, {6,3,9 ; B) int s[ ] [ 3] = {9,8,7,6,5,4; C) int s[3 ] [ 4] = {{1, 1, 2, {3, 3, 3, {3, 3, 4, {4, 4, 5; D) int s[ 3, 3] = {{1, {4, {6; 5.5 : char s1[ 80 ], s2 [80] ;,, A) scanf(% s% s, & s1, & s2) ; B) gets( & s1, & s2) ; C) scanf(% s% s, s1, s2 ) ; D) gets(% s%s, s1, s2) ; 5.6 A) if ( strcmp( str1, str2 ) ) printf(% s, str1 ) ; B) if ( str1 > str2 ) printf(%s, str1) ; 89

100 C) if ( strcmp( str1, str2 ) > 0 ) printf(%s, str1) ; D) if ( strcmp( str1) > strcmp( str2) ) printf(% s, str1) ; 5.7 # include < stdio.h > # include < string.h > { char s1 [80 ] = AB, s2 [80 ] = CDEF ; int i = 0 ; strcat( s1, s2 ) ; while( s1[ i + + ]! = \ 0 ) s2 [i] = s1[ i] ; puts( s2) ; A) CB B) ABCDEF C) AB D) CBCDEF 5.8, : AhaMA Aha < >, # include < stdio.h > { char s[ 80], c = a ; int i = 0 ; scanf( % s, s) ; while( s[i]! = \ 0 ) { if( s[ i] = = c) s [i] = s[i] - 32 ; else if( s[i] = = c - 32 ) s[i] = s [i] + 32; i + + ; puts( s) ; A) ahama B) AhAMa C) AhAMa aha D) ahama aha 5.9 # include < stdio.h > { char a[ ] = morming, t ; int i, j = 0; for(i = 1 ; i < 7 ; i + + ) if(a[j] < a[i] ) j = i ; t = a[j] ; a[j] = a[7] ; a[7 ] = a[ j] ; puts( a) ; A) mogninr B) mo C) morning D) mornin 5.10 s c 1 90

101 # include < stdio.h > { char s[80 ] ; int i, j; gets( s) ; for ( i = j = 0 ; s[i]! = \ 0 ; i + + ) if( s[i]! = c ) 1 ; s [j] = \ 0 ; puts( s) ; A) s[ j + + ] = s[i] B) s[ + + j] = s[i] C) s[ j] = s[i] ; j + + D) s[ j] = s[i] 5.11 C, # define M 10 { int i; ( 1) int a[ M] = {1,2,3,4,5, 6,7,8; ( 2) for(i = 1 ; i < = M ; i + + ) ( 3) printf(% d, a[i] ) ; 5.13 a a[ 2] [2 ] 3 a[ 4] [5 ] = {{1,2,3, {3,2,1,6, {1 ; 5.14 c 4 char c[ ] = { c language ; # include < stdio.h > { char c[ 6] ; int i = 0; for ( ; i < 6; c[i] = getchar( ), i + + ) ; for (i = 0 ; i < 6 ;putchar( c[i] ),i + + ) ; : p < > q < > 91

102 stru < > 5.16 : 9 33,, { int a[3 ] [3 ], sum1 = 0, sum2 = 0 ; / sum1,sum2 / int i, j; for( i = 0; i < 3; i + + ) for( j = 0; j < 3; j + + ) scanf( % d, 6 ) ; for( i = 0; i < 3; i + + ) { sum1 = sum1 + 7 ; sum2 = sum2 + 8 ; printf( sum1 = % d, sum2 = % d \ n, sum1, sum2) ; 5.17 a b { int a[ 2] [3] = {{1,2, 3, {4,5,6; int b[ 3] [ 2], i, j ; printf( array a: \ n ) ; for (i = 0; i < = 1 ; i + + ) { for ( j = 0; 9 ; j + + ) { printf(% 5d, a[ i] [ j] ) ; 10 ; printf(\ n ) ; printf( array b: \ n ) ; for (i = 0 ; 11 ; i + + ) { for (j = 0; j < = 1; j + + ) printf(%5d, b[i] [j] ) ; printf(\ n ) ; 5.18 a, 4, 92 # define N 20 { int a[ N ],i ; for(i = 0 ; i < N ; i + + ) scanf( % d, 12 ) ; for(i = 0 ; i < N; i + + )

103 { if( 13 ) 14 ; printf(% 3d, a[i] ) ; printf(\ n ) ; { int i, f[10] ; f[0 ] = f[ 1] = 1 ; for( i = 2; i < 10 ; i + + ) f[i] = f[i - 2] + f[ i - 1] ; for (i = 0 ; i < 10 ; i + + ) { if(i%4 = = 0) printf(\ n ) ; printf(%3d, f[i] ) ; { int x,y, i, a[8], j,u, v; scanf(% d, &x) ; / 15 / y = x ; i = 0 ; do { u = y/ 2 ; a[i] = y% 2 ; i + + ;y = u ; while(y > = 1 ) ; for(j = i - 1; j > = 0; j { int m = 1,n = 3, j,k = 4 ; int b[5] = {1,3, 5 ; while(m < = n & & k > b[m] ) m + + ; for( j = n - 1 ; j > = m ; j - - ) b[j + 1] = b[ j] ; b[ m] = k ; for (m = 0; m < = n; m + + ) printf( % 3d, b[m] ) ; - ) printf(% d, a[j] ) ; 93

104 5.22 a, ( ) ,,, 5.24,, 5.25,,, 5.26,, 5.27, 3, : 5.29, : AZ az BY by CX cx 26, i (26 - i + 1 ), 94

105 6 6.1, C, C, [6.1] { int a,b, c ; scanf( % d, % d, & a, & b) ; c = max(a, b) ; printf(max is % d, c) ; max (int x, int y) { int z; z = x > y? x :y; return (z) ; : 7,8 < > max is 8, main, max x y : (1 ),, (2 ) C,, ( ), C, C ( 3) C main, main, main main (4 ),,,, (: main ) 95

106 (5 ), :,,,,,, (6 ), :,,,,,,, 6.2 (1 ) : { ( ) (2 ) : ( 1, 2, ) { : int max (int x, int y) / / { int z ; / / z = x > y? xy; / / return (z) ; / / (3 ), : ( ) { : 96

107 void dummy( ) { ,, ( ),, ( ) : (1 ),,, (2 ),, :max (3, a + b), (,, 8 ) (3 ), (4 ),,,, (5 ) C,,,,,,,,,,,, [6.2] a b,, # include < stdio.h > { int a = 1, b = 2, c = 0 ; / a, b, c,1,2,0 / sum(a,b, c) ; /, a,b, c,1,2, 0 / printf( c = % d \ n, c) ;/ c,, z c / sum(int x, int y, int z) / x,y, z, x, y,z 1,2,0 / { z = x + y; / / /,x,y, z / 97

108 : c = 0,, z 6.3.2,, : (1 ) return return : return ( ) ; return ; return; return return, return, re turn, 6.1 max : max (int x, int y) { return ( x > y? xy) ;, return (2 ), return,,, (3 ),, : int max (float x, int y) char letter (char c1, char c2) double min (int x, int y ) C,, (4 ), return,,, 6.1 max z, max, max float,,, z float, max float (5 ), void ( ): void printstar( ) {,, 98,, void [6.3] 6.2,

109 # include < stdio.h > { int a = 1, b = 2, c ; / a,b, c, a,b 1,2 / c = sum(a,b) ; /, a,b, c / printf( c = % d \ n, c) ;/ c, c, c / int sum(int x, int y) / x,y 1,2, / { int z; / / z = x + y; return z ; /, x, y, z,z / : c = 3 return,, 6.3 return : ( ) ;,,,,, 6.4.2, : 1. : printstar ( ) ;, 2.,, : c = 2 max( a, b) 99

110 3., : m = max (a, max ( b, c) ) ; max( b, c), max ( )? (1 ) ( ) (2 ), # include, : # include stdio.h # include < stdio.h >,, : # include math.h # include < math.h > (3 ), ( ),, : ( ) ;, 6.4 [6.4] a b : # include < stdio.h > # include < math.h > / sqrt, / main ( ) { float add( ) ; / / 100 float a, b, c; scanf ( % f% f, & a, &b) ; c = add (a,b) ; printf ( Sum is % f \ n, c) ; float add( float x,float y) / add, float / { double z; z = sqrt( x) + sqrt(y) ; / sqrt( ( double) x) sqrt( ( double)y), sqrt double /

111 return (z) ; / return ( float)z ;, float / : < > Sum is :float add ( ) ;, add C, : (1 ) ( ),, (2 ),,, (3 ),,, : char letter ( ) ; / 3 / float f( ) ; int i( ) ; main ( ) { / / char letter (char c1, char c2 ) / letter / { float f( float x, float y) / f / { int i(float j, float k) / i / {,, (4 ) ANSI,,, (, ) : : ( 1, 2,, n) ; ( 1 1, 2 2,) ; ( ) 6.4, : float add( float, float) ; 101

112 float add( float x,float y) ; 6.4, 6.4 add,,,, [6.5], a b : { int a = 1, b = 2; swap( a, b) ; / a, b / printf( : a = % d, b = % d \ n, a,b) ; / a,b / swap(int a, int b) / a, b,a,b / { int c ; c = a ; a = b; b = c ; / a,b / printf( : a = % d, b = % d \ n, a,b) ; / a,b / /, a,b, c / : : a = 2,b = 1 : a = 1,b = 2, a b :,,, 6.1,,,, a, b 6 1 [6.6] a b c, 4.2, : # include < stdio.h > 102 # include < math.h >

113 { int a,b, c, max; scanf (% d, % d, % d, & a, &b, & c) ; max = find( a, b, c) ; /,, printf(max = % d \ n, max) ; int find(int x, int y, int z) { int max; max = x; if(abs(max) < abs (y) ) max = y; if(abs(max) < abs (z) ) max = z ; return max ; : 12, - 34,9 < > max = - 34 / 4.2,, return [ 6.7] ( 4.14 ) +, : # include math.h { float cal(float) ; / / float pi; pi = cal(1e - 6) ; printf( pi = % 10.6f \ n, pi) ; float cal(float e) { int s; float n, t, pi ; t = 1 ; pi = 0; n = 1.0; s = 1 ; while( (fabs( t) ) > = e) { pi = pi + t ; n = n + 2; s = - s; t = s/ n ; 103

114 pi = pi 4; return pi; : pi = [ 6.8] (4.24 ) : # include math.h main ( ) { int m, s = 0 ; for (m = 101 ; m < = 200 ; m = m + 2) s + = sum(m) ; printf( s = % d \ n, s) ; int sum(int m) { int i,k ; k = sqrt(m) ; for ( i = 2; i < = k ; i + + ) if (m% i = = 0 ) return 0 ; return m ; : s = 3167,,,,,,, C,, C,,,,, (main 3 ), : main ; a, a ; a ; b, b; b,, 104

115 b ; b, a ; a, a ; main a ; main :, [6.9 ] 1! + 2! + 3! + 4! ! (4.15) : : { float sum(int) ; / / float add; add = sum( 20 ) ; printf( add = %e, add) ; float sum(int n) { float fac(int) ; int i ; float s = 0 ; for(i = 1; i < = n ; i + + ) s + = fac(i) ; return s ; float fac(int i) { float t = 1 ; int n = 1; do {t = t n ; n + + ; while( n < = i) ; return t ; 2 : { float sum(int) ; float add ; add = sum( 20 ) ; printf( add = %e, add) ; float sum( int n) { int i ; float t = 1, s = 0 ; for (i = 1 ; i < = n; i + + ) {t = t i ; s = s + t ; 105

116 return s; : s = e + 18 [ 6.10] 20, 20 : # include < stdio.h > # include < math.h > int isprime( int) ; / isprime, / { int i, a, s; float b, c ; int add(int) ; / add mul main,main / float mul(int) ; / int, float / for ( i = 2; i < = 20 ; i + + ) { s = isprime(i) ; if( s) printf(% d, i) ; a = add( 20) ; b = mul( 20 ) ; c = b/ a ; printf(\ nc = % 7.0f \ n, c) ; int add( int n) { int i,s,sum = 0 ; for ( i = 2; i < = n ; i + + ) { s = isprime(i) ; if( s) sum + = i ; return sum ; float mul( int n) { int i,s ; float t = 1.0; for ( i = 2; i < = n ; i + + ) { s = isprime(i) ; if( s) t = i ; return t ; int isprime( int m) { int i ; for ( i = 2; i < = sqrt( m) ; i + + ) if(m% i = = 0) return 0; return 1; 106

117 : ( ) c = ( ),, 6.6, C : int f(int x) { int y,z ; z = f( y) ; return ( 2 z) ; f, f,, 6.3 : f1 f2, f2 f1, 6.4,,,,, if,, [ 6.11] n! n! = n ( n - 1 )!, n!, ( n - 1 )!, ( n - 1)!, 107

118 : ( n - 2 )!,, 2!, 1!, 1! 1 n! = 1 n( n - 1)! : int fac ( int n) { int c ; n = 0 1 n > 1 if ( n = = 0 n = = 1 ) c = 1 ; / n 0 1, n! 1 / else c = n fac(n - 1 ) ; / n > 1, n! / return c ; / c n!,n! / main ( ) { int i ; scanf(% d, &i) ; if(i < 0) printf( Data error! \ n ) ; else printf(% d! = % d \ n, i, fac(i) ) ; : 5 < > 5! = 120 main, fac [ 6.12], 603, : # include < stdio.h > 108 { void fun(int) ; int n; scanf(% d, &n) ; if( n < 0 ) { putchar(- ) ; n = - n; fun( n) ;

119 void fun( int k) { int n; n = k/ 10; if( n! = 0 ) fun (n) ; putchar (k % ) ; C,,,,, ,,, : float f1 (int a) / f1 / { int b, c; ( a, b, c, a,b, c) { int a,b; { int c ; c = a + b; (c ) (a, b ) : (1 ) main ( a, b), (2 ),,, f1 a b c main a b c, (3 ), f1 a, f1, 109

120 (4 ),,, [ 6.13] { int i, a = 0 ; : i = 1, a = 2 for (i = 1; i < = 2 ; i + + ) { int a = 1 ; / a, a / a + + ; printf( i = % d, a = % d \ n, i, a) ; / a, / printf( i = % d, a = % d \ n, i, a) ; / a a / i = 2, a = 2 i = 3, a = ,,,, : : int p = 1, q = 5 ; / p,q, / float f1 (int a) / f1 / { int b, c; / a,b, c / char c1, c2 ; / c1, c2, / char f2 (int x, int y) / f2 / { int i, j; / x,y, i, j / main ( ) { int m, n; : / m, n / (1 ) :,,, 110

121 ,,, (2 ), :, ;,,,,, ;,,,, (3 ),,,, extern, extern, [ 6.14] int max (int x, int y) / max / { int z; z = x > y? x :y; return (z) ; main ( ) {extern int a, b; /, / printf (% d, max (a,b) ) ; int a = 13,b = - 8 ; /, / : 13 (4 ),,, ( ), : ( ),, 111

122 6.6, : (1 ) (2 ) (3 ),, 6 6, :, ; ;,, C : (), :, : ( auto), ( static), ( register), (extern) (1 ),,,,, auto, : int f(int a) / f, a / { auto int b, c = 3; / b, c / auto, auto, auto, (2 ),,,,, static [6.15] void f(int c) { int a = 0; / 0, / 112 static int b = 0; / 0, / a + + ; b + + ; printf(% d: a = % d, b = % d \ n, c, a,b) ; { int i ;

123 for(i = 1; i < = 2; i + + ) f(i) ; / / : 1 : a = 1, b = 1 2 : a = 1, b = 2 a b, b,,, a b :, ( ),,,,,,,,,,, 0 ( ) ( ),,,, [ 6.16] { int i,b[5 ] ; for ( i = 0; i < 5 ; i + + ) printf( % d, b[i] ) ; / / printf(\ n ) ; printf( First time : \ n ) ; fun( ) ; /,a 0 / printf( Second time: \ n ) ; fun( ) ; /, a / fun( ) { int i ; static int a[5 ] ; /, / for ( i = 0; i < 5; i + + ) printf( % d, a[i] ) ; printf(\ n ) ; a[ 0] + + ; / a[0] / 113

124 : First time : Second time : ( ),, : (,, ),,,, (3 ),, C,, register [ 6.17] 1 5 : int fac ( int n) { register int i, f = 1 ; / i f, / for (i = 1 ; i < = n; i + + ) f = f i; return (f) ; main ( ) { int i ; for (i = 1, i < = 5; i + + ) printf(% d! = % d \ n, i, fac( i) ) ; f i, n, :, ( ),,,,,, : register static int a,b, c ; 114

125 a, b, c,,, 6.8.3, C,,, : (1 ), extern, file1.c a: int a ; main ( ) { file2.c file1.c a: extern int a ; power( n) { file2.c a, extern a, file1.c a (2 ), static file1.c file2.c static int a; extern int a ; fun (int n) { { a = a n; file2.c extern int a;, file2.c file1.c static a static ( ), (1 ) : 115

126 auto register extern static () ( ) () () (2 ), :, (, ) (, ) (, ) () () (, ) (3 ),, ( ) ( ) () ( ) () (4 ),,, , ( ) 6.9,,, 116

127 6.9.1,, static, : static ( ) : static int fun(a,b),,, 6.9.2, extern,, : extern int fun (a,b) fun, extern,, extern ( ) 6.1 A), B) main, C) main D) C 6.2 A), B) C) D) 6.3 A) C B), C) D) C,

128 A) float swap (int x, y) B) int max (int a, int b) C) char scmp(char c1, char c2) ; D) double sum( float x; float y) 6.5, A) B) C) D) 6.6 A) B) C) D) 6.7 fun (int x ) { printf(% d \ n, x) ; A) void B) int C) D) 6.8, A) B) C) D) 6.9 A) return B) C) D) 6.10, return, : A) B) C) D) 6.11 func( (exp1, exp2 ), (exp3, exp4, exp5) ) ; A) 1 B) 2 C) 4 D) , 118 A) B) C) D)

129 6.13, add, 3, 4 (1 ) void add(float a, float b) (2 ) { float c ; (3 ) c = a + b (4 ) return c ; f( ) { int a = 3; static b = 4 ; a = a + 1; b = b + 1 ; printf( a = % d, b = % d \ n, a,b) ; { f( ) ; f( ) ; { int i = 2,x = 5, j = 7 ; fun(j,6 ) ; printf( i = % d; j = % d ; x = % d \ n, i, j, x) ; fun(int i, int j) { int x = 7 ; printf( i = % d; j = % d ; x = % d \ n, i, j, x) ; { int x = 2, y = 3, z = 0 ; printf(# x = % d y = % d z = % d \ n, x, y, z) ; add( x, y,z) ; printf(@ x = % d y = % d z = % d \ n, x, y, z) ; 119

130 add(int x, int y, int z) { z = x + y; x = x x ; y = y y; printf( x = % d y = % d z = % d \ n, x, y, z) ; 6.19 double a = 5.0;, int n = 5; mypow( a, n) ;, a n double mypow( double x, int y) double mypow (double x, int y) { 6.20 e n f 1, f 2 f1 f 2 float f2 (int n) { float f1 (int x, int n) { { float exp = 1.0; int n,x ; : printf( Input a number : ) ; e x = 1 + x + x2 2! + x3 + (20 ) 3! scanf(% d, &x) ; printf(% d \ n, x) ; exp = exp + x ; Input a number :3 for( n = 2 ;n < = 19; n + + ) exp = exp + f1 ( x, n)/ f2 ( n) ; printf(\ nthe is exp( % d) = % 8.4f \ n, x, exp) ; The is exp( 3) = Sn 2 1, 3 2, 5 3, 8 5, 13 8, 21 13, n a = a + aa + aaa + + aaa, a : ( n 5), n 6.23 : 120

131 : x = xn + 1 = 1 2 xn a + a xn x ,, 6.26 n, 483, 483n, 6.27, 121

132 7 C, C C ( C ) C (,, ),,, C : (1 ) (2 ) (3 ) C, # (), : # define, ( ), # define : (1 ),, (2 ),, # define,,, : # define array - size 1000 int array[array - size] ;, # define : # define array - size

133 :, (3 ),, # define PI 3.l4l59 1 l,,, (4) C,, (5 ) # define,, # define,,, (6 ) # undef, : # define G 9.8 main ( ) { # undef G f1 ( ) # undef, G # undef, f1 G 9.8, (7 ),, [ 7.1] # define R 3.0 # define PI # define L 2 P I R # define S PI R R main ( ) { printf (L = % f \ ns = % f \ n, L, S) ; : L = S = ,, 123

134 : # define ( ), : # define S(a,b) a b area = S( 3, 2) ; S( 3, 2 ), 3 2 a b, 3 2 S( 3, 2) area = 3 2 : ( S ( 3, 2 ) ), # define (a b), ( ), (a b ),,, 7.1 : (1 ) # define, : # define PI # define S(r ) PI r r : area = S (a + b) ; a + b P I r r r, : area = PI a + b a + b; : area = PI (a + b) ( a + b) ;, : # define S(r ) PI (r ) ( r) S (a + b), a + b r, : PI ( a + b) (a + b) 7 1 (2 ),,, : # define S ( r) PI r r 124

135 : : S ( ), ( r ) PI r r area = S (a) ; : area = ( r) P I r r (a),,,,, : (1 ),,, S (a + b ), a + b, a + b (2 ),,,, (3 ),,,,,,,, (4 ), (5 ),,, (6 ),, ( ) [ 7.2] # define PR printf # define NL \ n # define D % d # define D1 D NL # define D2 D D NL # define D3 D D D NL # define D4 D D D D NL # define S % s main ( ) { int a,b, c,d ; char string[ ] = CH INA ; a = 1 ;b = 2 ; c = 3 ;d = 4 ; PR( D1, a) ; PR( D2, a,b) ; PR( D3, a,b, c) ; 125

136 PR( D4, a,b, c,d) ; PR( S, string) ; : CHINA 7.2, C # include, : # include < > # inciude 7.2 file1.c file2.c, 7.2( c), 7 2, ( link ),, (.OBJ),, h ( h head() ), print - format.h h, c, h : (1 ) include, n, n in clude (2 ),, ( ) 126

137 file1.c file2.h file3.h # include file2.c # include file3.c # include 7 3 file1.c file2.h file3.h # include file3.c # include # include # include file2.c 7.4 (3 ) # include,, file1.c : # include file2.h # include < file2.h >, : ( file2.h), (file1.c),, (< file2.h > ), file1.c 7.1 C A) C B) C) D) 7.2 A) B) C), D), 7.3 # define G 9.8 G A) B) 127

138 C) D) 7.4 # define K 2 # define X( k) ( ( K + 1 ) k ) C y = 2 ( K + X(5 ) ) ;, A) y B) y 65 C) D) y # define MIN( a, b) ( a) < (b)? (a) : ( b) { int m = 10,n = 15, k; k = 10 MIN (m, n) ; printf( % d \ n, k) ; A)30 B) 180 C) 15 D) A) include B) C) include D)# include, 7.7 # define FMT % d, { int b[ ] [ 4] = {1,3,5, 7,9,11,13, 15,17,19,21,23 ; printf( FMT, ( (b + 1) + 1) ) ; printf( FMT, b[2] [2 ] ) ; A) 1,11, B) 1,11 C) 11, 21, D) 11, : 128 # define X 5 # define Y X + 1 # define Z Y X/ 2 printf,

139 int a ; a = Y ; printf(% d \ n, Z) ; printf(% d \ n, - - a) ; A) 7 B) 12 C) 12 D) : # define MOD (x,y) x% y int z, a = 15, b = 100; z = MOD (b, a) ; printf(% d \ n, z + + ) ; A) 11 B) 10 C) 6 D) 7.10, 1 # define A p = A A; # define PR printf # define NL \ n # define D % d # define D1 D NL # define D2 D D NL { int a = 1, b = 2; PR ( D1, a) ; PR ( D2, a,b) ; 7.12 file2.c, 3 (1 ) file1.c : # define PI 3.14 float circle(float r) { float area = PI r r ; return (area) ; 129

140 (2 ) file2.c : # include file1.c { float r = 1; printf( area = %f \ n, circle( r) ) ; # define DOUBLE( r) r r { int y1 = 1, y2 = 2, t ; t = DOUBLE( y1 + y2 ) ; printf(% d \ n, t) ; # define MAX(a, b) (a > b? ab) + 1 {int i = 7, j = 9 ; printf(% d \ n, MAX (i, j) ) ; 7.15 for 6 # include stdio.h # define N 2 # define M N + 1 # define NUM ( M + 1) M/ 2 {int i, n = 0 ; for ( i = 1; i < = NUM ; i + + ) {n + + ; printf(% d, n) ; printf(\ n ) ; # define PRINT( V) printf(v = % d \ t, V ) {int a,b; a = 1 ;b = 2 ; PRINT(a) ; PRINT( b) ;

141 # define PR( a) printf(% d \ t, (int) (a) ) # define PRINT( a) PR(a) ;printf( ok! ) { int i, a = 1 ; for ( i = 0 ; i < 3 ; i + + ) P RI NT(a + i) ; printf(\ n ) ; 7.18, 7.19 swap( x, y),, a b 131

142 8 C, C,,,,,,,, 8.1, ( 8.1 ( a), i 2000, 3) 8 1, C,, i - pointer, i ( 2000 )i - pointer, : i - pointer = &i ; i -, i i - pointer i, i pointer i,, 8.1 ( b), i - pointer i, i - pointer i, i, i 2000, i

143 ,,, i - pointer, i - pointer i - pointer, 8.2, i - i : i = 3; i - pointer = 3 ; pointer, : 3 i - pointer C,, : int i, j; int pointer - 1, pointer - 2 ; i j, : pointer - 1, pointer - 2, : pointer - 1 = &i ; pointer - 2 = &j ; 8.3 : : 8 3 (1 ),, pointer - 1 point er - 2, pointer - 1pointer - 2 (2 ), pointer - 1,,, pointer - 1 pointer , ( ), (), : pointer - 1 = 100; ( pointer - 1, 100 ) 133

144 pointer - 2 = &f; ) : ( pointer - 2, f (1 ) & : : &a a (2 ) : ( ) : p p [ 8.1] main ( ) {int a,b; int p1, p2 ; / p1,p2, / a = 100; b = 10 ; p1 = & a ; / p1 a, p1 a / p2 = &b ; / p2 b, p2 b / p1 = p1 + 2 ; / a 2, a / ( p2) + + ; / b 1,, / printf (% d, % d \ n, p1, p2) ; / a,b / p1 = p2 ; / p1 p2 b / printf( % d, % d \ n, p1, p2 ) ; / b / : 102,11 11,11,, [8.2] a b, a b : main ( ) { int p1, p2, p, a, b ; scanf( % d, % d, & a, &b) ; p1 = &a ; p2 = &b; if ( a < b) {p = p1 ; p1 = p2 ; p2 = p; printf (\ na = % d,b = % d \ n \ n, a,b) ; printf (max = % d, min = % d \ n, p1, p2) ; : 5, 9 < > a = 5, b = 9 134

145 max = 9, min = 5 a = 5, b = 9, a < b, p1 p2 ( p ), 8.4 (a), 8.4( b), a b,, p1 p2 8 4, ( a b ) 8.2.3,, [8.3], a b 6.5, { int a = 1, b = 2; swap( & a, &b) ; / a, b / printf( 1: a = % d, b = % d \ n, a, b) ;/ p, q a,b p,q / swap(int p, int q) / p, q, a b. p, q a,b / { int c ; c = p; p = q; q = c;/ p, q a, b,a, b / printf( 2: % d, % d \ n, p, q) ; / a,b / : 2 : 2,1 1 : a = 2, b = 1 8.5( a), a b, 8.5( b), a b p q, p q a b (8.5 (c) ), ( 8.5 ( d) ) 135

146 8 5, a b, p q,, swap(int p, int q) { int c; c = p; p = q; q = c ; printf( 2: % d, % d \ n, p, q) ; c, c, c p c, c,,,, n, : n ; n ;, n ; 8.3, C,, (,, ) ( ) ( ),,, 8.3, 136

147 , ( a[ 3 ] ),, (, ) 8.3.1, : int a[10] ; / a 10 / int p; / p /, int, int : p = &a[0 ] ; a[ 0]p, p a 0, 8.6 C,, a, : p = &a[0 ] ; p = a ; a, p = a; a p, a p: int p = & a[ 0] ; 8 6 : int p; p = &a[0 ] ; /, p = &a[0 ] ; / : int p = a ; a (a[0 ]) p( p) p,, : p = 1 ; p ( 1 ) C p + 1 ( p 1), 137

148 , 4, p + 1 p ( )4, p + 1 p + 1d, d (, d = 2;, d = 4;, d = 1) p & a[ 0], : (1 ) p + i a + i a[i],, a i, 8.7 : a, a + i, p + i, a + id, p + 9 a + 9 &a[9 ], a[9 ] (2 ) ( p + i) (a + i)p + i a + i, a[ i],, a [i] ( a + i),,, a 1000,, a[ 3] : = 1006, 1006, a[ 3], [ ], a[i]a + i, (3 ), p[i] ( p + i),, : a[i],p[i], (a + i) (p + i) a, p, p = a 8 7 (4 ),,, p + + ; p - - ;, (5 ),,, [ 8.4] 10,, : { int i, a[ 10], p ; 138 for ( i = 0; i < 10 ; i + + ) scanf ( % d, & a[ i] ) ; for ( p = a ; p < a + 10 ; p + + ) / p < a + 10 p - a < 10,p - a p / printf ( % 4d, p) ; / / printf(\ n ) ;

149 , : (1 )p + + p,, p a (, a + + ), : for (p = a ; a < p + 10 ; a + + ) printf (% d, a) ; a,,, (2 ), [ 8.5] a 10 : main ( ) { int p, i, a[10] ; p = a ; for ( i = 0; i < 10 ; i + + ) scanf ( % d,p + + ) ; for ( i = 0; i < 10 ; i + +,p + + ) printf ( % d, p) ; printf(\ n ) ; : < > a, p a ( 8.8 ), for, p a ( 8.8 ), for, p &a[0 ], a + 10, p + +, p a 10 for : 8 8 for (i = 0,p = a ; i < 10; i + +, p + + ) printf (% d, p) ; p & a[ 0], (3 ) p a(p = a), : p + + ( p + = 1 ), p a[ 1], p, a[ 1] p + +, + +,, ( p + + ) p ( p), p + 1 p for : 139

150 : for (i = 0,p = a ; i < 10; i + + ; p + + ) printf (% d, p) ; for (i = 0,p = a ; i < 10; i + + ) printf (% d, p + + ) ; p, p, p ( p + + ) ( + + p) p, p, p, p p a( & a[ 0 ] ), ( p + + ), a[ 0 ], ( + + p), a[ 1] ( p) + + p 1, ( a [ 0 ] ) + +, a[ 0 ] = 3, (a [0 ] ) + +, a[0 ]4, 1, 1 p a i, : ( p - - )a[i - - ], p, p ( + + p)a[ + + i], p, ( - - p)a[ - - i], p, p + +,, p p 8.3.3,, : main ( ) f( int arr) {int array[10] ; { f(array) ; array,, arr,, : f(int arr) f(int arr[10] ) f(int arr[ ] ),, C ( 8.9 ), arr [8.6] score, 10, : float average( float array) /, array score / 140 { int i ; float aver, sum = 0 ;

151 8 9 for ( i = 0; i < 10 ; i + + ) sum = sum + array[i] ; / array[i] (array + i), score[i] / aver = sum/ 10; return (aver) ; main ( ) {float score[10], ave ; int i; printf ( Input 10 scores\ n ) ; for (i = 0; i < 10 ; i + + ) scanf(% f, & score[ i] ) ; / scanf( % f, score + i) ; / printf (\ n ) ; ave = average (score) ; printf ( Average score is % 5.2f, ave) ; : Input 10 scores: < > Average score is : (1 ) array,,,, (2 ), ( ) [8.7] : float average( float array, int n) { int i ; float aver, sum = 0 ; for ( i = 0; i < n; i + + ) sum = sum + array[i] ; aver = sum/ n; return (aver) ; 141

152 { float score - 1 [5] = {98.5,97,91.5,60,55 ; float score - 2 [10 ] = {67.5,89.5,99, 69.5, 77,89.5, 76.5, 54,60,99.5 ; printf ( Aaverage : % 6.2f \ n, average(score - 1,5 ) ) ; printf ( B - : Aaverage: Baverage : average : % 6.2f \ n, average( score - 2, 10) ) ;,,, ( n), average :,,,, [ 8.8] 10, (, ) ( 5.1( 4) ) : { int i, a[ 10 ] ; for( i = 0; i < 10 ; i + + ) scanf(% d, &a[i] ) ; for( i = 0; i < 10 ; i + + ) printf(% 4d, a[ i] ) ; printf( \ n ) ; fun( a, 10) ; for( i = 0; i < 10 ; i + + ) printf(% 4d, a[ i] ) ; printf( \ n ) ; fun(int a, int n) { int i, j, t ; for ( i = 0, j = n - 1 ; i < j ; i + +,j - - ) { t = a[i] ; a[i] = a[j] ; a[j] = t ; [8.9] 10,, (5.2 ) : 142 { int i, t, a[10] = {2, 4,1,6,5, 9,7,0,8,3 ;

153 for(i = 0; i < 10 ; i + + ) printf( printf(\ ninput t : \ n ) ; scanf(% d, & t) ; del(a, t) ; % 4d, a[i] ) ; for(i = 0; i < 9; i + + ) printf( % 4d, a[i] ) ; printf(\ n ) ; del(int a[10], int t) { int i, j; for(i = 0; i < 10 ; i + + ) if( t = = a[i] ) break; for(j = i ; j < 9; j + + ) a[j] = a[j + 1] ; [ 8.10] 10 (5.4 ) : { int i, a[10] ; for (i = 0; i < 10 ; i + + ) scanf( % d, & a[i] ) ; sort(a,10 ) ; for (i = 0; i < 10 ; i + + ) printf( % d, a[i] ) ; printf( \ n ) ; sort( int p[ ], int n) { int i, j, k, temp; for (i = 0; i < n - 1 ; i + + ) { k = i ; for (j = k + 1 ; j < n; j + + ) if( p[j] < p[ k] ) k = j; temp = p[i] ; p[ i] = p[ k] ; p[ k] = temp; [8.11] a 10, a, ( 5.6) : { int i, x, a[11] = {1,3,5,7,9, 11, 13,15,17,19 ; printf( Input x: \ n ) ; scanf( % d, &x ) ; for( i = 0; i < 10 ; i + + ) printf(% 4d, a[i] ) ; printf( \ n ) ; insert(a, x) ; 143

154 for(i = 0 ; i < 11; i + + ) printf( \ n ) ; insert(int a, int x) { int i, j ; i = 0; while( i < 10 & & a[i] < x) i + + ; printf( % 4d, a[i] ) ; for( j = 9; j > = i ; j - - ) a[j + 1 ] = a[ j] ; a[i] = x ; [ 8.12], : { int i,k, max; int a[10 ] = {3,4,9,1, 7,6, - 10,10, - 5,2; for ( i = 0; i < 10 ; i + + ) printf( % d, a[i] ) ; printf(\ n ) ; max = find(a, &k ) ; printf(max = % d,k = % d \ n, max, k) ; find(int a[ 10 ], int k) { int i, max; max = a[0 ] ; k = 0 ; for ( i = 0; i < 10 ; i + + ) if (max < a[ i] ) { max = a[i] ; k = i; return max ; 8.3.4,, a: int a[3 ] [ 4] = {{1,3, 5,7, {9, 11,13,15, {17,19,21,23; : (1 ) a, ( 2000 ), a a 0, a 0 (2 ) a + 1 a 1, a (2008) 144

155 (3 ) a[0 ], a[ 1], a[2 ] ( ), (0, 1, 2 ), a[0 ] 0 0, a[ 0] 2000 (4 ) a[i] + j i j, (a[ i] + j) i j a[0 ] + 2 ( a[ 0] + 2)0 2 (5 ) a[i] (a + i), 8 10 a[ 2] (a + 2) 2, 2 0, &a[2 ] [ 0] (6 ) a[i] [j], ( a[i] + j), ( ( a + i) + j) i j (7 ) a + 1 a[ 1]2008 a + 1, a[1 ] ( ( a + 1 ) ),, 1 0 (8 ), : int ( p) [ 4] ; / p / p 4, : main ( ) { int a[3] [4 ] ; int p1, ( p2) [4 ] ; p1 = &a[3 ] [ 4] ; / p1 / p2 = a + 1; / p2 / : p1 = a + 1 ; p2 = & a[3] [4] ; / / [1 ] C, 1. [8.13] 145

156 { char string[ ] = I love China! ; printf (% s \ n, string) ; string, ( 8.11 ) 2., [8.14] main ( ) { char string = I love China! ; printf (% s \ n, string) ; C,, string, ( )( 8.12 ) :, \ 0 ( 8.12 ),,,, [8.15] a b( ) main ( ) 146 {char a[ ] = I am a boy.,b[ 20], p1, p2 ; int i; for (p1 = a, p2 = b; p1! = \ 0 ; p1 + +, p2 + + ) p2 = p1;/ / p2 = \ 0 ; / /

157 printf ( String a is : % s \ n, a) ; printf ( String b is : % s \ n,b) ; p1 p2 p1 p2 a b, p1 p2, p1 \ 0 p1 p2, ,,, : (1 ),, (), (2 ), char str[14] ; str = I love China! ; / str,, /, : char a ; a = I love China! ; a, (3 ) : char a = I love China! ; : char a ; 147

158 a = I love China! ; : char str[14] = { I love China! ; : char str[14] ; str[ ] = I love China! ;, (4 ),,,,,,,,, : char str[10] ; scanf (% s, str ) ;, : char a ; scanf (% s, a) ; a, a (&a), a, a,, a, a (5 ) [ 8.16] main ( ) {char a = I love China! ; / a I / a = a + 7 ; / a C / printf (% s, a) ; / China! /, :, ( ) [8.17] main ( ) 148 {char a = I LOVE CHINA. ; int i; printf ( The sixth charcter is %c \ n, a[ 5] ) ; / E/

159 for (i = 0; a[i]! = \ 0 ; i + + ) printf ( % c, a[i] ) ; / I LOVE CHINA. / a[i] ( a + i), a i, : (6 ), printf, char format ; : format = a = % d,b = %f \ n ; printf ( format, a,b) ; printf ( a = % d,b = % f \ n, a,b) ; format, printf, : char format[ ] = a = % d, b = % f \ n ; printf ( format, a,b) ;, : char format[ ] ; format = a = % d,b = % d \ n ;,, N ULL, : int p; p = NULL ; NULL stdio.h, 0, p : p = NULL ; p = \ 0 ; p = 0 ; NULL, # include < stdio.h >, 8.4.3,,,,, 149

160 [ 8.18] (5.11 ) : # include < stdio.h > # include < string.h > { int i, j ; char ch[ 80 ] ; gets(ch) ; puts(ch) ; j = strlen(ch) - 1; fun(ch, j) ; puts(ch) ; fun(char p, int j) { int i; char t, q; q = p + j ; : asdfgh < > asdfgh hgfdsa for ( ; p < q; p + +,q - - ) { t = p; p = q; q = t ; [8.19], strlen ( 5.12 ) : # include < stdio.h > { int len; 150 char a[ 80 ] ; gets(a) ; puts( a) ; len = lenth(a) ; printf(% d \ n, len) ; lenth(char p) { char q = p; / p q a / while( q! = \ 0 ) q + + ; / q, p / return q - p; / q - p /

161 asdfgh < > asdfgh 6 [ 8.20], strcat ( 5.13 ) : # include < stdio.h > { char s1 [80 ], s2 [40 ] ; printf( \ n Input string1: ) ; gets( s1) ; printf( \ n Input string2: ) ; gets( s2) ; scat( s1,s2 ) ; printf( \ n New string: % s, s1) ; scat(char s1, char s2) { while( s1! = \ 0 ) s1 + + ; : while( s2! = \ 0 ) { s1 = s2; s1 + + ; s2 + + ; s1 = \ 0 ; Input string1 : country < > Input string2 :side < > New string: countryside [8.21], from to strcpy,\ 0 \ 0 ( ) : # include < stdio.h > # include < string.h > { char from[80], to[80] ; printf( Input string: ) ; scanf(% s, from) ; strcopy( from, to) ; 151

162 printf( Copied string: % s \ n, to) ; strcopy(char from, char to) { int i; : for (i = 0; i < = strlen(from) ; i + + ) to[i] = from[i] ; Input string: student < > 15 ) Copied string: student [ 8.22], s1 s2 strcmp ( 5. : # include < stdio.h > { int a; char s1 [80 ], s2 [80 ] ; gets( s1) ; gets( s2) ; puts (s1) ; puts( s2) ; a = strcomp( s1,s2) ; if(a > 0 ) printf( ( s1: % s) > ( s2 : % s ) \ n, s1, s2 ) ; if(a = = 0 ) printf( ( s1: % s) = ( s2 : % s ) \ n, s1, s2) ; if(a < 0 ) printf( ( s1: % s) < ( s2 : % s ) \ n, s1, s2 ) ; strcomp(char s1, char s2) { while( s1 = = s2 & & s1! = \ 0 ) {s1 + + ; s2 + + ; : boy < > return s1 - s2; girl < > boy girl ( s1 :boy) < ( s2 :girl) , 152

163 ,, : main ( ) { int max (int, int ) ; / max / { int ( p) (int, int) ; / p / int a,b, c ; p = max; / max p / scanf( % d, % d, & a, &b) ; c = ( p) (a,b) ; / a, b,max(a,b) / printf( max = % d \ n,c) ; int max (int x, int y) / max / { int z; if ( x > y) z = x ; else z = y; return (z) ; 8.14 p max : (1 ) : 8 14 ( ) ( 1, 2,... ) ;, (2 ), ( ) (3 ) ( p) (int, int),,,, (4 ),, : p = max; p, p = max (a, b) ; (5 ), ( p ) ( p ), ( p), : p, a b, c c = ( p) (a,b) ; (6 ), p + np + + p

164 (7 ) 8.5.2,, : ( sub), ( x1 x2 ), x1 x2 sub, f1 f2, sub f1 f2, : f1 f 2 sub(int ( x1) (int), int ( x2 ) (int, int) ) / x1 x2 / { int a,b, i, j ; a = ( x1) (i) ; / f1 / b = ( x2) (i, j) ; / f2 / i j f1 f2 sub x1 x2 sub,, sub, f1 f2 x1 x2, x1 x2 f1 f2, 8.15, sub, x1 x f1 f2, ( x1) (i) f1 (i), ( x2 ) ( i, j) f2 (i, j), sub, sub 8.6 :,, # include < stdio.h > char fun(char ) ; / / { char ch = a, p, q; 154 p = & ch; q = fun (p) ; / q,q = bag ; / puts( q) ; char fun(char s)

165 { char t = big ; ( t + 1) = s; / s p ch / return t ; / / : bag : ,,, ,,,,, : [ ] : int p[4] ; int ( p ) [ 4] ;,,, ( 8.16 ( a) ),,,,, ( ),, 8.16 ( b),, 8.16 (c),, (, ), 8.16 ( d ),, ( ) [8.23],, 0 : # include < stdio.h > # include < string.h > { int i,k ; char temp, str[ ] = { Follow, QBASIC, Great, FORTRAN, Computer ; k = 0 ; for ( i = 1; i < 5 ; i + + ) if( strcmp( str[ k],str[i] ) < 0 ) k = i ; 155

166 8 16 if( k! = 0) { temp = str[ 0] ; str [0] = str[ k] ; str[ k] = temp; printf( The largest string is \ n% s \ n,str[ 0] ) ; : QBASIC 8.7.2, p q, p q,, : char p ; char q = abc ; p = & q; p q, p q,, p a,, 8.16( c) name ( ) name p( ), name ( 8.17 )name, p [8.24] 156 { char str[ ] = { ENGLISH,MATH,MUSIC, PHYSICS, CHEMISTRY ; char q; int num ;

167 8 17 q = str; for ( num = 0 ;num < 5 ;num + + ) printf(% s \ n, ( q + + ) ) ; : ENGLISH MATH MUSIC PHYSICS CHEMIST RY str,, str [ 0 ] ENGLISH, str[ 1 ] MATH q str,, q q str, str[ 0 ],, ( q ) q 1, q str,,

168 8.7.3 main, main : main ( ), main, : main (int argc, char argv) argc argv main main,, main ( ), main : 1 2 n argc,, argc1 : file1 China Beijing argc 3argv ( ), 8.19, argv [ 0 ] file1, argv [ 1 ] China, argv[ 2] Beijing 8 19 [8.25] file.c, main (int argc, char argv[ ] ) { argc - - ; argv + + ; while( argc > 0) { printf( % s, argv) ; : argc - - ; argv + + ; c : > file Computer and C Language < > : Computer and C Language 158

169 8.1 a char a = \ nmy Name is Zhang Li. \ \ n ; A) 26 B) 27 C) 28 D) C, A) B) C) D) 8.3 p1 p2,, a, A) a = p1 B) a = p1 + p2 C) a = p1 - p2 D) p1 = a - p2 8.4 A) cde char s = abcde ; s + = 2 ; printf( % d,s ) ; B) C) cascii D) c 8.5 : int p[ 4] ; p A) B) C), D) 8.6 a[3 ] [ 4], 2 3 A) & a[ 2] [3 ] B) a[ 2] + 3 C) ( a + 2 ) + 3 D) (a[ 2] + 3) 8.7 char language[ ] = { FORTRAN, BASIC, PASCAL, JAVA, C ; : language[1 ] > language[3 ] 159

170 A) B J B) BASIC JAVA C) FORTRAN PASCAL D) F P A) int ( p) [4 ] B) int p[ 4] C) int ( p[ 4] ) D) int ( p) [ ] 8.9 A) C main, B) C main, argc argv C) main, D) main (int argc, char argv), argc , char a[4 ] [12] = { China, Japan, Franch, England, p[4] ; int i ; for (i = 0 ; i < 4 ; i + + ) p[i] = a[ i] ; A) a[i] B) p[i] C ) p D) p 0i < fun ( int p1, int p2) { if( p1 > p2 ) printf( % d \ n, p1) ; else printf(% d \ n, p2) ; { int a = 3, b = 7; fun ( & a, &b) ; 8.12, int a[3 ] [ 5], i, j;, 0i < 3,0j < 5, a[i] [j] 160 : (1 ) & a[i] [j] (2 ) a[i] + j (3 ) ( a + i) + j (4 ) & a[ 0] [0 ] + 2

171 (5 ) a[0 ] {char s[ ] = { China, Japan, Franch, England ; char p; int i; p = s + 2 ; printf(% s \ n, p) ; c8.c main( int argc,char argv[ ] ) { while (argc > 1 ) { + + argv; printf(% s \ n, argv) ; - - argc ;, DOS : c8 C Language 8.15 : int s[ 2] [ 3] = {0, ( p) [ 3] ; p = s; p char str[ ] = abc \ 0def \ 0ghi, p = str ; printf( % s, p + 5 ) ; 8.17, 8.18, 8.19, 1 ; 0, level 8.20, ,,

172 8.22, 8.23,,, 8.24, 8.25,,, 3, March, 8.26, m m, 162

173 9 9.1, C, ( structure), : struct { ; : struct student { int num ; ; char name[20] ; char sex ; int age; float score; char addr [30 ] ; struct student ( struct, ), ( num, name, sex, age, score, addr),, 9.2, int char,, : 1. struct student,, : struct student student1,student2 ; struct student, student1 student2 struct stu 163

174 dent, struct student, : struct { ; : struct student { int num ; char name[20] ; char sex ; int age; float score; char addr [30 ] ; st udent1,student2 ; 3. : struct { ;,, : (1 ) : struct date 164 { int month;

175 int day; int year ; ; st ruct student { int num ; char name[20] ; char sex ; int age; struct date birthday; / struct date / char addr [30 ] ; student1, student2; birthday struct date, 6 ( = ), student1 stu dent2 struct student, 61 ( = )struct student (2 ) : struct student { int num ; float score ; struct student next ; / next struct student / ;, : struct date { int month; int day; int year ; birthday = {11,1,1960 ; 9.3,, :..( ),, : student1.num = 10010; 165

176 : student1 num (1 ),,, : student1.birthday.year = 1959 ; : student1.birthday student1 birthday, birthday, (2 ) ( ): sum = student1.score + student2.score ; student1.age + + ; (3 ) C, : struct date { int month; int day; int year ; n1, n2 = {5,20,1999 ; n1 = n2;, n1 n2 (4 ),, : scanf (% d, & student1.num) ; ( student1.num ) printf(% o, &student1) ; (student1 ), : scanf (% d, % s, %c, % d, %f, % s, & student1) ;, [9.1], struct aa { long num ; name[20 ] ; stu = {990001, zhang hua bin ; stu.name[0 ] = Z ; stu.name[ 6] = H ; stu.name[ 10 ] = B ; printf( : % ld, : % s \ n,stu.num, stu.name) ; : :990001, : Zhang Hua Bin 166

177 9.4 ( ),, 1.,, : struct student { int num ; char name[20] ; char sex ; int age; float score; char addr [30 ] ; ; struct student stu[3] ;, : struct student {int num ; stu[ 3] ; : struct { int num ; stu[3 ] ; 9.3(), , : 167

178 struct student : { int num ; char name[20] ; char sex ; int age; float score; char add[30] ; stu[3 ] = {{10101, Li Lin, M,18, 87.5, 103 Beijing Road, {10102, Zhang Fun, M, 19, 99, 130 Shanghai Road, {10104, Wang Min, F, 20,78.5, 1010 Zhongshan Road ; stu,, stu[ ] = {{, {, {;,, : 9 4 struct student {int num ; ; struct student stu[ ] = {{, {, {;,,, : = { ; [ 9.2] : strct aa { long num ; char name[20] ; struct bb { int age ; struct aa first ; stu[2 ] ; (1 ) stu[ 1] 18, , zhang hua bin, ; (2 ) z h b,? (3 ) stu[ 1] stu[0 ] : 168

179 (1 ) scanf( % d% ld% s, & stu[ 1].age, & stu[ 1].first.num, stu[ 1].first.name) ; (2 ) stu[1 ].first.name[ 0] = Z ; stu[1 ].first.name[ 6] = H ; stu[1 ].first.name[ 10 ] = B ; (3 ) strcpy( stu[ 0].first.name, stu[1 ].first.name) ; 9.5,,, [9.3] {struct student { long int num ; ; char name[ 20 ] ; char sex; float score ; struct student stu - 1, p; p = &stu - 1 ; stu - 1.num = 89101; strcpy( stu - 1.name,Li Lin ) ; stu - 1.sex = M ; stu - 1.score = 89.5; printf ( No.: % ld \ nname: % s \ nsex: % c \ n score : % f \ n, stu - 1.num, stu - 1.name,stu - 1.sex,stu - 1.score) ; printf (\ n No.: % ld \ n name: % s \ n sex: %c \ n score : % f \ n, ( p).num, ( p).name, ( p).sex, ( p).score) ; p, struct student printf ( p).num, ( p).num p - > num- > :, ; ( p).; p - > : stu - 1.num, ( p).num, p - > num 169

180 9.5.2,, [9.4] struct student { int num ; char name[20] ; char sex ; int age; ; struct student stu [ 3] = {{10101,Li Lin,M, 18, {10102, Zhang Fun,M, 19, {10104, Wang Min, F, 20; {struct student p; printf (No. Name sex age \ n ) ; for ( p = stu; p < stu + 3; p + + ) printf (% 5d % - 20s % 2c% 4d \ n,p - > num,p - > name,p - > sex, p - > age) ; : LiLin M Zhang Fun M Wang Min F 20, p struct student, (p stu ), stu : p = &stu[2].num [9.5] : struct aa { int i ; char c ;t ; struct cc { int m ; struct aa n; ; struct cc w, p = & w ;,? : p - > m = 0; / p w m 0 / p - > n = & t; / t p w n / 170

181 p - > n - > i = 1; / p - > n, t, p - > n - > i t.i / p - > n - > c = A ; / p - > n - > c p - > n t c / :, [ 9.6] : struct aa { int i; struct aa n; w, t, p = & w ;,? : p - > i = 0 ; p - > n = & t; p - > n - > i = 1; p - > n - > n = \ 0 ; n :,,, ; (), ( ) ; AN SI C, ( ),,,,,,,,,, 9.4 main print, print p struct student, & stu [i] stu void print ( struct student ) ; main ( ) { int i ; for (i = 0 ; i < 3; i + + ) print( & stu[ i] ) ; void print ( struct student p) { printf (% 5d % - 20s % 2c % 4d \ n, p - > num,p - > name, p - > sex,p - > age) ;, 171

182 , 9.5 ( ),, head,,, :,, head,,,, N ULL ( ), 9 5 :,, ( head ), :,, : struct student {int num ; float score ; struct student next ; ; next,, struct student ( next ),, struct student, next,, next 9.7,, 172

183 9 7,, 9.8 : struct student,,,,, C 9 8 (1 ) malloc( size) size, ( ),, 0 (2 ) calloc( n, size) n size ;, 0 (3 ) free( ptr) ptr, ptr calloc malloc, n size, ptr C malloc calloc void (),, typedef C (int, char, float, double, long ), typedef : typedef int INTEGER; : typedef float REAL ;, INTEGER int, REAL float, int i, j; float a, b; INTEGER i, j; REAL a, b;, : typedef struct { int month; 173

184 int day; int year ; DATE ; DATE, DATE : DAT E birthday; ( struct DAT E birthday; ) DAT E p; (p ) : (1 ) typedef int N UM[100 ] ; ( N UM ) NUM n; ( n ) (2 ) typedef char STR ING; ( STRING ) ST RING p, s[ 10 ] ; ( p, s ) (3 ) typedef int ( POINTER) ( ) ( POINTER, ) POINTER p1, p2; ( p1, p2 POINTER ), : (1 ) ( : int i; ) (2 ) ( : i COU NT ) (3 ) typedef(: typedef int COU NT) (4 ) : : typedef, ,, ( [1 ] ) [9.7] : head, p, q, malloc ( ), head, p, q ( 9.9), n s, p, 0,, 9 9 n 0, p (, 9.10 (a) ), 174

185 9 10 p q - > next, next ( 9.10 ( b) ), q = p, q ( 9.10(c) ) n s n 0, p (, 9.11 ( a) ), n s p q - > next, ( 9.11 ( b) ) q = p, q ( 9.11 (c) ), n 0,, p NULL q - > next( ( 9.12 ) ),

186 9 12, : (1 ) head, p q head ; (2 ) ; (3 ) 0, p, (7 ) ; (4 ) ; (5 ) q p, q p ; (6 ), (3 ) ; (7 ) q next N ULL, head, p, q p : # include < stdio.h > 176 typedef struct st udent { long num ; float score; struct student next ; LIST ; /, LIST / LIST creat( ) / / { long n; float s ; LIST head, p, q; head = ( LIST ) malloc( sizeof( LIST) ) ; / head / p = q = head; scanf(%ld, % f, &n, &s ) ; / & p - > num, &p - > score, 0 while ( n! = 0 ) / { p = (LIST ) malloc (sizeof (LIST ) ) ; / p / p - > num = n ; p - > score = s; / / q - > next = p; / / q = p; / (q - > next ; ) / / q / scanf( % ld, % f, &n, &s) ;

187 q - > next = NULL ; / / return ( head) ; / head / void print( LIST head) {, 9.8 / { LIST head; head = creat( ) ; / / print( head) ; / / : (1 ) sizeof sizeof( double) 8 (2 ) malloc,,, struct student, (3 ) creat 2. [9.8] : head, p, p, p,, : void print( LIST head) / head / { LIST p; p = head - > next ; / p / while( p! = NULL) { printf(%ld % 5.1f \ n, p - > num, p - > score) ; p = p - > next ; / p / 3. [9.9] num ( ), : (1 ) ; (2 ),, 9.13 : # include < stdio.h > 177

188 typedef struct st udent {... LIST ; LIST creat( ) {... void print( LIST head) {... insert(list head, LIST stud) { LIST p, q; q = head ; p = head - > next ; while( p! = NULL & & stud - > num > p - > num ) { q = p; p = p - > next ; / /

189 stud - > next = p; q - > next = stud; /, { LIST head, stu ; head = creat( ) ; print( head) ; scanf(%ld, % f, &stu.num, &stu.score) ; insert( head, &stu) ; print( head) ; / main,, head, stuinsert, stu studp q, q, p 1, 9.13 (a) while,, p ( p! = N ULL ) p (, stud - > num > p - > num), 9.13, p 89101q p, p ( p = p - > next ),, 9.13 ( b) stud - > num 89107, p - > num 89109, stud - > num > p - > num, ( p q )while, p stud - > next, p, 9.13( c), q - > next = stud, q next, q ( p ), 9.13 ( d) :,,,, (,,,, ),,, 4. [9.10], 179

190 ,,, : (1 ) ; (2 ), # include < stdio.h > typedef struct st udent {... LIST ; LIST creat( ) {... void print( LIST head) {... int del (LIST head, long num) { LIST p, q; if( head - > next = = NULL) /, / { printf( List is null! \ n ) ; return 0; q = head; / q / p = head - > next ; / p / while( p! = NULL & & num! = p - > num ) { q = p; p = p - > next ; / / if( p = = NULL) /, / else { int a ; { printf( Not been found. \ n ) ; return 0 ; { q - > next = p - > next ; long num ; free( p) ; / p / return 1; LIST head; head = creat( ) ; print( head) ; scanf(%ld, &num) ; a = del( head, num) ; if(a! = 0 ) print( head) ; /, /,,,, 180

191 ,, ( 9.14 ), ( 1000),,, ( union), : union { ; 9 14 : union data { int i ; char ch; float f; a,b, c ; : union data { int i ; ; char ch; float f; union data a,b, c; union data, a, b, c union data, : union { int i ; char ch; float f; a,b, c ;,, a, b, c 4 (4 ), = 7 181

192 9.7.2,,, a, b, c, : a.i (i) a.ch a.f (ch) (f), : printf ( % d, a) ;, printf( % d, a.i)printf(% c, a.c) : (1 ),,,,, 2.,, : a.i = 1 ; a.c = a ; a.f = 1.5;, a.f, a.i a.c (3 ), : & a, & a.i, & a.c, &a.f, (4 ),,,, : union { int i ; char ch; float f; a = {1, a,1.5; ( ) a = 1; ( ) m = a ; ( ) (5 ),, ( ) (6 ),,, 182

193 , 9.1 : struct stu {int a ; float b; stu type; A) struct B) struct stu C) stutype D) stu = stud age, struct student { int num ; char name[20] ; int age ; stud = {101, Li fun, 18, p = & stud; A) ( p).age B) stud.age C) student.age D) p - > age 9.3, A) B) C) D) 9.4 : struct pupil { char name[ 20 ] ; int age ; int sex; pup[5 ], p = pup ; scanf, A) scanf(% d, pup[ 0].name) ; B) scanf(% d, & pup[ 0].age) ; C) scanf(% d, & ( p - > sex ) ) ; 183

194 D) scanf( %d, & p - > age) ; 9.5 { union data { int num ; a; float score; char name; a. score = 98.5; a.name = China ; a.num = 901 ; printf( % f \ n, a.score) ; A) 98.5 B) 901 C) China D) 9.6 : struct st { int n ; ; struct st next ; struct st a[ 3] = {5, &a[1 ],7, & a[2],9,\ 0, p; p = & a[ 0] ; 6 A) + + p - > n B) ( p).n + + C) p > n D) p - > n A) typedef, B) typedef C) typedef D) typedef IBM PC C,, ss struct s { int m ; ss; char c; double d; A) 8 B) 1 C) 11 D) # include < stdio.h >

195 { struct date { int year, month, day; today; printf(% d \ n, sizeof( struct date) ) ; A) 6 B) 8 C) 10 D) # include < stdio.h > union un { int k; char zf[2 ] ; ch ; { ch.k = 20 ; ch.zf[ 0] = 0 ; ch.zf[ 1] = 10; printf(% d \ n, ch.k) ; A) 10 B) 20 C) 2560 D) 9.11 { struct cmplx {int x; int y; cnum[ 2] = {1,3,2,7 ; printf( % d \ n, cnum[ 0].y/ cnum[0 ].x cnum[1 ].x) ; A) 0 B) 1 C) 3 D) : struct num { int a ; int b; float f; n = {1, 3,5.0; struct num pn = &n; 185

196 2 pn - > b/ n.a + + pn - > b 1, ( pn).a + pn - > f struct s { int num ; ; char name[ 20] ; int age; { struct s stud[3 ] = {{101, Li, 18, {102,Wang,19, {103, Zhang, 21; fun( stud + 2) ; fun( struct s p) { printf( % s \ n, ( p).name) ; 9.14, st ruct student { int num ; ; char name[ 20] ; int age; { struct student p, stud [ 3 ] = {{101, Li, 18, {102,Wang, 19, { 103, Zhang, for( 21; 4 ; p < stud + 3 ;p + + ) printf(% s \ n, 5 ) ; { struct EXAMPLE { struct { int x; int y; in; int a; int b; e ; e.a = 1 ; e.b = 2; e.in.x = e.a e.b; e.in.y = e.a + e.b;

197 printf( % d, % d, e.in.x, e.in.y) ; 9.16 bt, struct ps { double i ; ; char arr[20] ; { struct ps bt ; printf(% d \ n, 7 ) ; union ks { int a; int b; ; union ks s[4 ] ; union ks p; { int n = 1, i ; printf(\ n ) ; for(i = 0; i < 4; i + + ) { s[i].a = n ; s[i].b = s[i].a + 1 ; n = n + 2; p = &s[0 ] ; printf( % d,, p - > a) ; printf( % d, + + p - > a) ; 9.18, head data next, data int, next, 9.19, 9.20, ( data int ) ( next) 9.21,, ( 0000 ), 9.22,, ( 0000 ), 9.23,, 187

198 10 C & < < > > : (1 ), (), (2 ), : 10.1, 1, 1, 0, & : 0 & 0 = 0 ; 0 & 1 = 0 ; 1 & 0 = 0 ; 1 & 1 = 1 : 3 & 5 8,, 3 5, 3 : ( & ) 5 : ,, 3 & , 1 : 0 0 = 0; 0 1 = 1; 1 0 = 1; 1 1 = 1 :

199 ( ) a 4 1, a , XOR :, 0 () ; 1( ) : 00 = 0; 01 = 1; 10 = 1; 11 = 0; : ( 57, 071 ) () ( 42, 052 ) ( 19, 023 ) , 023( ) :, () (1 ), (0 ) 10.4, ( ),, 0 1, 1 0, ( ) , , < <, : a = a < < 2 a 2, 0 a = 15, , , 60, 1 2, = 415 < < 190

200 2 = 60, 4,, 1, ( 8 ), a, a = 64, 0, 2, 1 a a 2 < < 1 a < < , a = , 2, 0, C 2, 2 n n 10.6 > >, a > > 2 a 2,,, 0 a = 017 : a , a > > , n 2 n,, 0, 0 ( ), 0, 1(), 0 1, 0, 10, 1,, a a: a > > 1 : a > > 1 : () (), a > > , Turbo C C,, : & =, =, > > =, < < =, =, a & = b a = a & b, a < < = 2 a = a < < 2 191

201 10.8 ( long int ) ( a & b, a long, b int ), b, 16 0 ; b, 1; b, 0,, 10.1, A) 4 B)2 C) 4 D) , A) 4 B) 2 C) 4 D) a b int a = 1,b = 2 ; a = ab; b = ba; a = ab; A) a = 1, b = 2 B) a = 2, b = 2 C) a = 2, b = 1 D) a = 1, b = char a = 56 ; a = a&056 ; printf( % d, % o \ n, a, a) ; A) 40,50 B) 1, 1 C) 56, 60 D) 50, & & 5 1, 3 & 5 2, 3 5 3, & 3 < < < < &

202 10.9 a, ( 0), : a = a & a 8 1, 8, : a = a a 4 ( 0 1, 1 0), : a = a a 47 { unsigned a, b, c, d; scanf ( % o, & a) ; b = 11 ; c = (0 < < 4) ; d = b& c; printf( % o \ n,d) ; a 4, 4 4, : a = 12 a < < ( 16-4) { char a = 0x95,b,c ; b = (a & 0xf) < < 4; c = (a & 0xf0) > > 4; a = b c; printf( % x \ n, a) ; getbits, (, 0), : getbits ( value, n1, n2 )Value ( ), n1, n2 getbits ( , 5, 8), , , ( 1, 3, 5,, 15 ) ,, 193

203 C (file), : ( ),,,,, ( ), C ( ), ( ), ASCII ASCII ( text), ASCII, ASCII,,,,, ( ASCII ),,,,, C, ( ),, C ( record) ( PASCAL ), C ( ) ( ), C, C,, ANSI, 11.2 C,,, ( ),, F ILE FILE, F ILE,,, FILE F ILE efile [ - MAXF ILE] ; 194

204 efile[ ], MAXFILE, MAXFILE,, : F ILE fp; fp FILE, fp,, n, n ( F ILE ), n (, ), 11.3,, ( fopen ) ANSI C, fopen( ), fopen : FILE fp; fp = fopen(, ) ; r( ) r + ( ) / w( ) w + ( ) / a( ) a + ( ) / rb( ) rb + ( ) / wb( ) wb + ( ) / ab ( ) ab + ( ) / : if ( ( fp = fopen( file1, r ) ) = = NULL) { printf( cannot open this file \ n ) ; exit(0 ) ; 195

205 : (1 ), fopen N ULL ( N ULL stdio.h 0) (2 ),,,,, (3 ), :,, stdin, stdout stderr, ( ) stdin, ( fclose ),,,,, fclose, fclose : fclose( ) ; : fclose( fp) ; fopen fp, fclose :, 0;, ferror 11.4,, fputc fgetc (putc getc ) 1. fputc fputc, : fputc (ch, fp) ; ch,, fp, fopen fputc( ch, fp) (ch )fp fputc, 196

206 ;, EOF, EOF stdio.h, fgetc fgetc,, fgetc : ch = fgetc ( fp) ; fp, ch fgetc, ch fgetc, EOF, EOF stdio.h - 1, : ch = fgetc ( fp) ; while (ch! = EOF) { putchar (ch) ; ch = fgetc ( fp) ;, - 1, EOF,, ANSI C feof, feof( fp ) fp, feof (fp) 1 (), 0(), : while (! feof (fp) ) { c = fgetc ( fp) ;, feof( fp)0,! feof( fp ) 1, c ( ),, feof(fp) 1,! feof( fp) 0, while [11.1], file.dat, # : # include < stdio.h > { F ILE fp; char ch ; if( ( fp = fopen( file.dat, w ) ) = = NULL) 197

207 { printf( Cannot open file. \ n ) ; exit(0) ; ch = getchar( ) ; while(ch! = # ) { fputc(ch, fp) ; putchar( ch) ; ch = getchar( ) ; fclose( fp) ; [ 11.2] 11.1,, : # include < stdio.h > { FILE in, out ; char ch; if( (in = fopen( file.dat, r ) ) = = NULL) printf( Cannot open file.dat. \ n ) ; exit( 0) ; if( (out = fopen( file0.dat, w ) ) = = NULL) printf( Cannot open file0.dat. \ n ) ; exit(0 ) ; while(! feof(in) ) { ch = fgetc(in) ; if(ch > = a& & ch < = z ) ch = ch - 32 ; fclose(in) ; fputc(ch,out) ; fclose(out) ; fputs fgets 1. fputs fputs, : fputs (str, fp) ; str, fp fputs, 0;, 0 2. fgets fgets, fgets 198

208 fgets(str,n, fp) ; fp n - 1, str n - 1 EOF, \ 0, fgets str fread fwrite ANSI C ( fread fwrite), : fread ( buffer,size,count, fp) ; fwrite ( buffer,size,count, fp) ; : buffer:, fread,, fwrite, () size: count : size fp: fread fwrite, count,, fread fwrite, : fread( f,4, 2, fp) ; f, 4, fp 2 ( 4 ), f, fread 2 : struct student - type { char name[10] ; int num ; int age; char addr [30 ] ; stud[ 40] ; stud 40, ( ), for fread 40 : for (i = 0 ; i < 40 ; i + + ) fread ( & stud[i], sizeof( struct student - type),1, fp) ;, for fwrite 199

209 for (i = 0 ; i < 40; i + + ) fwrite ( &stud[ i],sizeof ( struct student - type),1, fp) ; fprintf fscanf fprintf fscanf printf scanf, : fprintf fscanf : fprintf(,, ) ; fscanf(,, ) ; : fprintf( fp,% d, % 6.2f, i, t) ; i t %d %6.2f fp i = 3, t = 4.5, : 3, 4.50, fscanf ASCII : fscanf(fp, % d, % f, &i, & t) ; : 3, i, 4.5 t fprintf fscanf,,, ASCII,,,, fprint fscanf, fread fwrite 11.5,,,,,, rewind rewind, rewind : rewind( ) 200

210 [ 11.3] stu.dat, 0, : # include < stdio.h > { F ILE fp; int num ; float score ; if ( ( fp = fopen( stu.dat, w + ) ) = = NULL) { printf( Can t open stu.dat. \ n ) ; exit( 0) ; scanf( % d% f, &num, & score) ; while( num! = 0) { fprintf( fp,% d % f \ n, num, score) ; scanf(% d% f, &num, &score) ; rewind(fp) ; while(! feof( fp) ) { fscanf( fp,% d% f, & num, &score) ; fclose( fp) ; printf( num = % d,score = % f \ n, num, score) ; fseek,,,,, ( ), ( ), ( ) fseek fseek : fseek(,,) 0, 1, 2, 0, 1, 2, L, 11.1 C, 201

211 A) B) C) D) 11.2 fp, fopen, A) fp = fopen( file1, ab + ) B) fp = fopen( file1, r + ) C) fp = fopen( file1, wb + ) D) fp = fopen( file1, ab ) 11.3 fgetc, A) B) C) D) B C 11.4 fputc, A) EOF B) 1 C ) 0 D) 11.5 : struct st { char name[ 8] ; int num ; float s [4] ; student[50 ] ; student, fp, A) fwrite( student, sizeof( struct st ), 50, fp ) ; B) fwrite( student, 50 sizeof( struct st ), 1, fp ) ; C) fwrite( student, 25 sizeof( struct st ), 25, fp ) ; D) for( i = 0; i < 50; i + + ) fwrite( student, sizeof( struct st ), 1, fp ) ; 11.6 fread fwrite / A) B) C) D) 11.7 : fseek( fp, - 20L, 2) ; A) 20 B) 20 C) 20 D) rewind A) B) C) D) 11.9 fclose, 202 A) 0 B) - 1 C) 1 D)

212 11.10 fp fopen, fp = fopen( file1.c, r ) ; 2, fopen, , : 5 stdin 6 7, count # include < stdio.h > { FILE fp; long count = 0; if ( ( fp = fopen( let ter.dat, 8 ) ) = = NULL) {printf( cannot open file \ n ) ; exit(0 ) ; while(! feof( fp) ) { 9 ; 10 ; printf( count = % ld \ n, count) ; fclose( fp) ; 11.15, # include < stdio.h > struct rec { int num ; float total; { FILE f ; reout( f = fopen( bin.dat, rb) ; reout( f ) ; fclose( f ) ; 11 ) { struct rec r ; while (! feof( f) ) { fread( &r, 12,1, f ) ; printf( % d, % f \ n, 13 ) ; 203

213 11.16 feof( fp) fp, feof(fp) 14, fread( p,50, 2, fp) p, fread 16, fseek ( fp, 100L, 1 ) fp ( 100L L ) file1.c file2.c # include < stdio.h > { FILE 19 ; fp1 = fopen( file1.c, r ) ; fp2 = fopen( file2.c, w ) ; while(! feof(fp1 ) ) putchar (getc(fp1 ) ) ; 20 ; while(! feof(fp1 ) ) putc( 21 ) ; fclose( fp1) ; fclose( fp2) ; stud - dat i 204 # include < stdio.h > struct studen t - type { char name[ 10] ; int num ; int age ; char sex ; stud[ 10 ] ; { int i ; FILE 22 ; if( (fp = fopen( stud - dat, rb ) ) = = NULL) { printf( cannot open file \ n ) ; exit(0 ) ; scanf(% d, &i) ; fseek( 23 ) ;

214 fread( 24, sizeof( struct student - type),1, fp) ; printf(% s% d % d%c \ n,stud[i].name, fclose(fp) ; stud[i].num, stud[i].age, stud[i].sex) ; 11.21,, test,! , 3, (,, ),, stud employee, : 11.24, 205

215 1 ASCII

216 2 C au to break case char const continue default do double else enum extern float for goto if int long register return shor t signed sizeof static struct switch t ypedef union unsigned void volatiel while 3 1 ( ) [ ] - >! ( ) & 1 () sizeof 3 / % 2 () < < > > 6 < < = > > = 2 () 2 () 2 () 7 = =! = 2 () 207

217 8 & & & 12 13?: 2 () 2 () 2 () 2 () 2 () 3 () 14 = + = - = = / = % = = = & = = = 2 15, ( ) 4 C, C,, 1, 7 2 : (1 ) (0 ) (0x ) (L 1 ) (2 ) ( ), 208

218 (3 ) ( ) (4 ) 3 (1 ),, double, double (2 ), ( 0 1) (3 ), (4 ) ( ), ( float)a (5 ) ( ) : 1, 2,, n 1, 2,, n n (6 ) = (7 ) :? 1: 2, 1 ;, 2 (8 ), p - 2 p1 - p2& a ( p p1 p2 ),, (, ) 209

219 4, (1 ) : int short long unsigned char float double struct union typedef (, int ) : struct { ; union { ; typedef : typedef ; : typedef int COUNT ; (2 ) : auto static register extern (, auto ) : : static float a,b, c; : extern static, auto register 210

220 5 : ( ) extern static, : static int max (int x, inty) { int z; z = x > y? x :y; return(z) ; 6, ( ) ( ),, 7 (1 ) ; (2 ) ; (3 ) ; (4 ) ; (5 ) : (1 ) if () if () 1 else 2 (2 ) while( ) (3 ) do while ( ) ; (4 ) for (1; 2; 3 ) (5 ) switch () { case 1: 1; case 2: 2; 211

221 case n: n; default; n + 1; case default,, case, case, break switch (6 ) break (7 ) continue (8 ) return (9 ) goto 8 # define # define ( 1, 2,, n ) # undef # include (< > ) # if # ifdef # ifndef # else # endif 5 C C C, ANSI C C, C, ANSI C C, C (,, ),,, C, 1, : # include < math.h > 212

222 abs int abscint x) ; x acos double x) ; acos ( double cos - 1 (x) x asin double x) ; asin ( double sin - 1 ( x) x atan double atan x) ; ( double tan - 1/ (x/ y) atan2 double atan2 ( double x, bouble y) ; tan - 1 ( x/ y) cos double cos ( double x ) ; cos( x) x cosh double cosh x) ; ( bouble x cosh( x) exp double exp ( double x) ; e x fabs double x) ; fabs ( double x floor double floor x) ; ( double x fmod double fmod ( double x, double y) ; x/ y frexp double frexp ( double avl, int eptr) ; val ( )x 2 n, val = x 2 n, n eptr x 0. 5 x < 1 log double log(double x) ; logex,ln x log10 double log10 ( double x) ; log10x modf double modf ( double val, double iptr) ; val val, iptr pow double pow (double x, double y) ; x y rand int rand(void) ; sin double sin( double x) ; sinx x sinh double x) ; sinh ( double x sinh (x ) 213

223 sqrt double sqr t ( double x) ; x x 0 tan double tan ( double x) ; tan( x) x tanh double x) ; tanh ( double x tanh (x) 2. ANSI C < string.h >, < ctype.h > C ANSI C, isalnum int isalnum (int ch) ; ch ( alpha) ( numeric) 1; 0 ctype.h isalpha int isalpha (int ch) ; ch, 1;, 0 ctype.h iscntrl int iscntrl (int ch) ; ch (, 1; ASCII 0 0x1F, 0 ) ctype.h isdigit int isdigit (int ch) ; ch ( 09), 1, 0 ctype.h isgraph int isgraph ( int ch) ; ch, 1; ( ASCII ox21, 0 ox7e ), ctype.h islower int islower ( int ch) ; ch ( a z), 1;, 0 ctype.h isprint int isprint ( int ch) ; ch, 1; ( ), ASCII, 0 ox20 ox7e ctype.h ispunct int ispunct (int ch) ; ch ( ),, 1;, 0 ctype.h isspace int isspace (int ch) ; ch (), 1;, 0 ctype.h 214

224 isupper int isupper ( int ch) ; ch ( A Z), 1;, 0 ctype.h isxdigit int isxdigit ( int ch) ; ch 16 ( 09, A F, af), 1;, 0 ctype.h strcat char strcat(char str1, char str2) ; str2 str1,str1 \ 0 st r1 string.h strchr char strchr ( char str, int ch) ; str ch,, string.h strcm p int strcmp ( char str1,char str2 ) ; str1 < str2, str1 str2 str1 = str2, 0 string.h str1 > str2, st rcpy char strcpy (char str1, char str2) ; str2 str1 str1 string.h strlen unsigned in t strlen ( char str) ; str ( \ 0 ) string.h strstr char strstr(char str1 char str2 ) ; str2 str1, string.h (str2 ) tolower int tolower (int ch ) ; ch ch ctype.h toupper int toupper ( int ch) ; ch ch 3, # include < stdio.h > stdio.h 215

225 clearerr void clearerr ( file fp) ; close int close (int fp) ; 0,, - 1 ANSI creat int creat ( char filename, int mode) ; mode, - 1 ANSI eof inteof( int fd) ;, 1 ; 0 ANSI fclose int fclose ( F ILE fp) ; fp, 0, 0 feof int feof ( FILE fp) ;, 0 fgetc int fgetc ( F ILE fp) ; fp, EOF fgets char fgets (char buf, int n, FILE fp) ; fp buf, ( n - 1 ),, buf NULL fopen F ILE fopen ( char filename, char mode) ; mode filename, ( ), 0 fprint f int fprintf ( FILE fp, char format, args, ) ; args format fp fputc int fputc ( char ch, F ILE fp) ; ch fp, ; EOF fputs int fputs ( char str, F ILE fp) ; str fp 0, 0 fread int fread (char pt, unsigned size, un signed n, FILE fp) fp size n, pt, 0 216

226 fscanf int fscanf ( FILE fp, char format, args, ) ; fp for mat args (args ) fseek int fseek ( F ILE fp, long offset, in t base) ; fp base, offset, - 1 ftell fwrite getc long ftell ( FILE fp) ; int fwrite ( char ptr,unsigned size, un signed n, FILE fp) ; int getc ( FILE fp) ; fp fp ptr n size fp fp fp,, EOF getchar int getchar( void) ;, - 1 getw int getw ( F ILE fp) ; fp ( ) ANSI, - 1 open int open (char file name, int mode) ; mode filename ( ), - 1 ANSI format prin tf int printf ( char format args,) ; args,, putc int putc( int ch, FILE fp) ; ch fp ch, EOF 217

227 pu tchar int putchar ( char ch) ; ch ch, EOF puts int puts(char str) ; str, \ 0, EOF putw int pu tw ( int w, F ILE fp) ; w ( ) fp ANSI, EOF read int read ( int fd, char buf, unsigned count) ; fd count buf 0, - 1 ANSI rename int rename ( char oldname, char newname) ; oldname 0,,newname - 1 rewind void rewind ( F ILE fp) ; fp, scanf int scanf ( char format args,) ; format args args, args EOF, 0 write int write (int fd, char buf, unsigned count) ; buf count fd ANSI

228 4 ANSI, calloc( )malloc( ) free( ) realloc( ), C, ANSI stdlib.h, C malloc.h stdlib. h ANSI void void, C char, void char calloc void calloc ( unsigned n, unsign size) ; n,, 0 size free void free( void p) p malloc realloc void malloc ( unsigned size) ; void realloc(void p; un signed size) ; size f,, 0 sizesize 6 ( C ) 1 2, 3, 4 () 1 219

229 2 3 : ( ), ( RAM ROM), ( ), ( ) ( ) 4, ;, ; ( ) 5( ) ; ( ) 6; 7 8 () DOS 1 2 DOS 3 4DOS, : ; ( TYPE, COPY, DEL, REN, XCOPY, ATT RIB) ; (DIR, MD, CD, RD, TREE, TATH) ; ( FORMAT, DISKCOPY, CHKDSK) ; ( VER, DATE, TIME, CLS, PROMP T, HELP ) ; (, ) ; () VINDOW 1 Windows 2 Windows : 3 Windows :,,,, ( QBASIC FOR TRAN PAS CAL C FOXBASE, ) : 1( ) 220

230 2 3,, C () C 1, main C () 1 C () 2 C 3 4 C ( ) () 1,, 2, 3 4 goto () 1 if 2 switch 3 () 1 for 2 while do while 3 continue break 4 () 1 2 () , 5,, 221

231 6 7 (), 8 () 1 : ; 2 () 1, ,, main () ( ) ( ) 1 2, ( ) 1 2 ( ) ( ( I/ O ), ( I/ O ) 1( FILE ) 2( fopen, fclose) 3 (fputc, fgetc, fputs, fgets, fread, fwrite, fprintf, fscanf ), ( rewind, fseek ) 7 (C ) ( :, 25, C , 100 ) ( ( 1) ( 40) 1, (41 )( 50) 2, 60 ) A) B ) C ) D),, 222

232 (1 ), A) CPU B) CPU C) CPU D) CPU (2 ), BIOS A) RAM B) ROM C) D) (3 ) 2424 A) 2 B) 24 C) 32 D) 72 (4 ) bit A) B) C) D) (5 ) A) B) C) D) (6 ) BB A) 187 B) 188 C) 185 D) 186 (7 ), A) B) C) D) (8 ) 3 5 A) 360KB B) 720KB C) 1 44MB D) 1 2MB (9 ) 0 1 A) 0 1 B) 0 2 C) 0 4 D) 0 8 (10) DOS A) B) C) COMMAND.COM D) (11) K1, K2, K3, K4, A) COPY K1 + K2 + K3 K4 B) COPY K1 + K2 + K3 + K4 C) COPY K1 + K2 + K3 + K4 K4 D) COPY K4 + K1 + K2 + K3 (12) A) AUTOEXEC.C B) AUTOEXEC C) ATX.BAT D) AUTO.TXT (13), A) DIR \ > PRN B) TYP E \ > PRN C) DIR > \ PRN D) TYPE > PRN (14) ABC.EXE XYZ, XYZ A) ABC < XYZ > XYZ B) ABC < XYZ > > XYZ 223

233 C) ABC < < XYZ > XYZ D) ABC > > XYZ (15) \ A \ B \ C, \ A A) MD \ A \ C B) CD..C) MD \ A \ B \ A D) MD \ A \ B (16) A : C, A \ D2, A QR.C, A) \ D2 \ D4 \ QR.C B) D4 \ QR.C C) A: D4 \ QR.C D) AD2 \ D4 \ QR.C (17) DOS, A) TYPE AAB.FOR > CON B) TYPE? AB.FOR C) COPY.C CON D) COPY CON PRN (18) A, AB1.TXT C XYZ.TXT, A) COPY C: \ XYZ.TXT + AB1.TXT B) COPY AB1.TXT > > C: \ XYZ.TXT C) TYPE AB1.TXT > C: \ XYZ.TXT D) AB1.TXT + C: \ XYZ.TXT > C: \ XYZ.TXT (19) A) DISKCOPY A: A: B) DISKCOPY A: C: C) DISKCOPY C: A: D) DISKCOPY C: D: (20) \ A \ B \ C \ D \ XU, \ A.C,.FOR, A) COPY \.C.FOR B) COPY.C \ A \.FOR C) COPY.FOR \.C D) COPY \ A \.C.FOR (21) A) \ \ B) \ C) 074D) \ 0 (22) : 224

234 char a ; int b; float c ; double d a b + d - c A) float B) int C) char D) double (23) xyz C A) ( x < = y ) & & (y < = z) B) ( x < = y)and( y < = z) C) ( x < = y < = z) D) ( x < = y) & ( y < = z) (24) a = 1, b = 2, c = 3, d = 4, : a < b? ac < d? ad A) 4 B) 3 C) 2 D) 1 (25) x int,, x x = 10 ; x + = x - = x - x ; A) 10 B) 20 C) 40 D) 30 (26) C A) x = 3, y = 5 B) a = b = 6 C) i - - ; D) y = int ( x ) ; (27) x y z t int,, t x = y = z = 1; t = + + x + + y& & + + z ; A) B) 2 C) 1 D) 0 (28) i int, f float, : scanf( i = % d, f = % f, & i, &f) ; i f, A) 100 < > < > B) i = 100, f = < > C) 100 < > < > D) x = 100 < > y = < > (29) x y int,, y for ( y = 1, x = 1; y < = 50; y + + ) { if( x > = 10) break; if( x% 2 = = 1) { x + = 5 ; continue; x - = 3 ; A) 2 B) 4 C) 6 D) 8 (30) : char x[ ] = abcdefg ; char y[ ] = { a, b, c, d, e, f, g ; 225

235 A) x y B) x y C) x y D) x y (31) A) B) C) D) (32) a b int, b a = 1; b = 10 ; do { b - = a; a + + ; while( b - - < 0 ) ; A) 9 B) - 2 C) - 1 D) 8 (33) j int, for for (j = 10; j > 3 ; j - - ) { if(j% 3)j - - ; - - j; - - j; printf(% d, j) ; A) 6 3 B) 7 4 C) 6 2 D) 7 3 (34) : # define N 3 # define Y ( n) ( ( N + 1 ) n) : z = 2 ( N + Y(5 + 1) ) ;, z A) B) 42 C) 48 D) 54 (35) p1 p2 int, k int, A) k = p1 + p2; B) p2 = k; C) p1 = p2; D) k = p1 ( p2) ; (36) : int arr[ ] = {6,7,8,9,10; int ptr; 226 ptr = arr; ( ptr + 2) + = 2 ;

236 printf( % d, % d \ n, ptr, ( ptr + 2) ) ; A) 8, 10 B) 6,8 C) 7, 9 D) 6, 10 (37) { int i, k, a[10 ], p[3 ] ; k = 5 ; for(i = 0 ; i < 10; i + + ) a[i] = i ; for(i = 0 ; i < 3 ; i + + ) p[i] = a[ i (i + 1 ) ] ; for(i = 0 ; i < 3 ; i + + ) k + = p[i] 2 ; printf(% d \ n,k) ; A) 20 B) 21 C) 22 D) 23 (38), m int a[2] [3 ] = {{ 1,2, 3, {4,5, 6 ; int m, p; p = &a[0 ] [ 0] ; m = ( p) ( ( p + 2) ) ( ( p + 4) ) ; A) 15 B) 14 C) 13 D) 12 (39) char arr [ ] = ABCDE ; char ptr; for(ptr = arr;ptr < arr + 5; ptr + + ) printf(% s \ n,ptr) ; A) ABCDE B) A C) E D) ABCDE (40) { int x, i; for(i = 1 ; i < = 50; i + + ) { x = i ; if( + + x %2 = = 0) if(x %3 = = 0) if( x% 7 = = 0 ) B D BCDE C C CDE D B DE E A E printf(% d, i) ; 227

237 A) 28 B) 27 C) 42 D) 41 (41) # include < stdio.h > { union { int k; char i[ 2] ; s, a ; s = & a ; s - > i[ 0] = 0x39; s - > i[1 ] = 0x38 ; printf(% x \ n,s - > k) ; A) 3839 B) 3938 C) D) (42) # include < stdio.h > { int a, b, c = 246; a = c/ 100 % 9; b = ( - 1 ) & & ( - 1 ) ; printf(% d, % d \ n, a,b) ; A) 2, 1 B) 3, 2 C) 4,3 D) 2, - 1 (43) : int ( ptr) ( ) ; A) ptr B) ptr int C) ptr, int D) ptr, int (44) 228 # include < stdio.h > struct stu

238 { int num ; ; char name[ 10 ] ; int age ; void fun (struct stu p) { printf(% s \ n, ( p).name) ; { struct stu students[3] = { {9801, Zhang,20, fun ( students + 2 ) ; {9802,Wang, 19, {9803, Zhao,18 ; A) Zhang B) Zhao C) Wang D) 18 (45) : typedef union struct date { long i; int k[5] ; char c ; DATE ; { int cat ; DAT E cow; double dog; too; DAT E max ; printf( % d,sizeof(struct date) + sizeof(max) ) ; A) 26 B) 30 C) 18 D) 8 (46) { char a[ ] = programming, b[ ] = language ; char p1, p2 ; int i; p1 = a ; p2 = b; for (i = 0; i < 7; i + + ) if( ( p1 + i) = = ( p2 + i) printf( % c, (p1 + i) ) ; A) gm B) rg C) or D) ga (47) void fun (int a, int b, int c) { a = 456; b = 567; c = 678; 229

239 { int x = 10, y = 20,z = 30 ; fun( x,y, z) ; printf(% d, % d, % d \ n,z,y, x) ; A) 30,20, 10 B) 10, 20,30 C) 456, 567, 678 D) 678, 567, 456 (48) int fun (int x, int y, int cp, int dp) { cp = x + y; dp = x - y; { int a,b, c,d; a = 30 ; b = 50 ; fun( a, b, &c, &d) ; printf(% d, % d \ n, c,d) ; A) 50,30 B) 30,50 C) 80, - 20 D) 80, 20 (49) { int i, j ; for (j = 10 ; j < 11 ; j + + ) { for(i = 9 ; i < j; i + + ) if(! ( j% i) )break; if(i > = j - 1) printf( % d, j) ; A) 11 B) 10 C) 9 D) (50) 230 # include stdio.h int abc( int u, int v) ; { int a = 24, b = 16, c; c = abc(a,b) ; printf(% d \ n,c) ;

240 int abc(int u, int v ) { int w ; while ( v) { w = u %v; u = v; v = w ; return u; A) 6 B) 7 C) 8 D) 9 ( 2, 40 ) (1 ) , (2 ) DOS, COMP 2 (3 ) C, DOS A.DAT DOS 3 ( 4) XYZ.BAK.FOR, DOS 4 (5 ) DOS PATH WST.TXT, DOS 5 (6 ) x y int, x = 1, y = 2, x/ y (7 ) i j k int, for, k 7 for(i = 0, j = 10 ; i < = j; i + +, j - - ) k = i + j; (8 ) : int a[3] [2 ] = {10,20, 30,40,50,60, ( p) [2 ] ; p = a ; ( ( p + 2) + 2) 8 (9 ) 9 # include < stdio.h > int fun(int x, int y) { static int m = 0, i = 2 ; i + = m + 1 ; m = i + x + y; return m ; { int j = 4, m = 1, k; 231

241 k = fun (j, m) ; printf( % d,, k) ; k = fun (j, m) ; printf( % d \ n, k) ; (10) fun :, void fun (char str[ ] ) { char m ; int i, j ; for(i = 0, j = strlen( str) ; i < 10 ; i + +, j - - ) { m = str [i] ; str[i] = 11 ; str[j - 1 ] = m; printf(%s \ n, str) ; (11) :,,, # include ctype.h # include stdio.h { char str[ 81], sptr; int i; for(i = 0 ; i < 80; i + + ) { str[ i] = getchar( ) ; if( str[i] = = \ n ) break ; str[i] = 12 ; sptr = str; while( sptr) putchar( sptr 13 ) ; (12), ASCII : abcdefg abceef, # include < stdio.h > { char str1 [100],str2 [100], c ; int i, s; printf(\ n Input string 1 : \ n ) ; gets( str1) ; printf(\ n Input string 2 : \ n ) ; gets( str2) ; i = 0;

242 while( (str1 [i] = = str2[ i] ) & & ( str1[i]! = 14 ) ) s = 15 ; pintf(% d \ n, s) ; i + + ; (13 ) :,, test.txt, # include < stdio.h > { FILE fp; char str[100] ; int i = 0; if ( ( fp = fopen ( test.txt, 16 ) ) = = NULL) { printf( Can t open this file. \ n ) ; exit(0 ) ; printf( Input a string: \ n ) ; gets( str) ; while( str[i] ) { if ( str[i] > = a& & str[i] < = z ) str[i] = 17 ; fputc( str[i], fp ) ; i + + ; fclose( fp) ; fp = fopen( test.txt, 18 ) ; fgets( str, 100, fp) ; printf(% s \ n, str) ; fclose( fp) ; (14) (long ), # include.< stdio.h > { char b[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F ; int c[64],d, i = 0, base; long n; printf( Enter a number: \ n ) ;scanf( % ld, &n) ; printf( Enter new base: \ n ) ; scanf(% d, &base) ; do { c[i] = 19 ; i + + ; n = n/ base; 233

243 while( n! = 0) ; printf( Transmite new base : \ n ) ; for( - - i; i > = 0; - - i) { d = c[i] ; printf(% c, b 20 ) ; ( C ) ( (1 )( 40 )1 ; (41) (50) 2 ) (1 ) B (2 ) B ( 3) D (4 ) D ( 5) B (6 ) A (7 ) B ( 8) C (9 ) D ( 10 ) A (11) D (12) C ( 13 ) A (14) B ( 15 ) D (16) C (17) B ( 18 ) A (19) A ( 20 ) A (21) C (22) D ( 23 ) A (24) D ( 25 ) B (26) C (27) C ( 28 ) B (29) C ( 30 ) C (31) D (32) D ( 33 ) B (34) C ( 35 ) B (36) D (37) B ( 38 ) A (39) D ( 40 ) D (41) A (42) A ( 43 ) C (44) B ( 45 ) B (46) D (47) A ( 48 ) C (49) B ( 50 ) C ( 2, 40 ) ( 1) (5 ) (1 ) 1 AUTOEXEC.BAT (2 ) 2 (3 ) 3 COPY A:.DAT PRN ( COPY A:.DAT ) (4 ) 4 REN XYZ \.BAK.FOR RENAME XYZ \.BAK.FOR ( REN RENAME XYZ/.BAK ) (5 ) 5 ATTRIB + R WS T.TXT (6 ) (7 ) 7 10 (8 ) ( ATTRIB + R ) AT TRIB WST.TXT + R ( ATTRIB WST.TXT )

244 (9 ) 9 8,17 (10) 10 strlen( str)/ 2 strlen( str)/ strlen (str) j j str[j - 1] ( str + j - 1 ) (11) 12 \ (12) 14 \ str[i] - str2 [i] (13) 16 w w + wt w + t wt + 17 str[i] - 32 str[i] - ( a- A )str[i] - a+ A 18 r r + r + t rt + (14) 19 n%base 20 [ d] 8 1 C 1.1 C 1.2 D 1.3 B 1.4 B { ; / 8 / ,

245 1.13 : { printf( \ n ) ; 1.14 : printf( Very Good \ n ) ; printf( \ n ) ; { int a,b, c, max; scanf( % d % d% d, &a, &b, & c) ; if(a > b) max = a ; else max = b; if(max < c) max = c ; printf( max = % d \ n, max) ; : < > max = A 2.2 D 2.3 D 2.4 B 2.5 C 2.6 D 2.7 B 2.8 A 2.9 C 2.10 C

246 B, : { char c1 = C, c2 = h, c3 = i, c4 = n, c5 = a ; c1 + = 4 ; c2 + = 4 ; c3 + = 4 ; c4 + = 4 ; c5 + = 4 ; : printf(: %c%c%c%c%c \ n, c1, c2, c3,c4, c5) ; : Glmre D 3.2 D 3.3 C 3.4 B 3.5 B 3.6 A 3.7 A 3.8 C 3.9 B 3.10 C 237

247 a = 4, c = < > 2 a = 4, c = a = 3, b = 5, c = 6.50, d = , e = a , 144, 64, u1 = 10000, u2 = % i = 10000, j = % decimal = - 31, hex = ffe1, octal = , unsigned = scanf(% d% f % f % c% c, &a, & b, & x, &c1, & c2 ) ; 3.19 : aA { float r, s, v; 3.20 : int h; scanf( % f% d, & r, & h) ; s = r ; v = s h/ 3 ; : printf( : %4.2f, : % 4.2f \ n, s,v) ; :6.71, : 6.71 { float f, c; printf( Enter f: \ n ) ; scanf( % f, &f) ; c = (f - 32 ) 5/ 9 ; printf( c = %4.2f \ n,c) ; 238 :

248 3.21 : Enter f: 15.6 < > c = # include < stdio.h > { char c1,c2; c1 = getchar ( ) ; c2 = getchar ( ) ; putchar( c1) ; putchar( c2) ; printf(\ nc1 = % c, c2 = % c \ n, c1, c2 ) ; : ab < > ab c1 = a, c2 = b 4.1 D 4.2 C 4.3 D 4.4 B 4.5 D 4.6 D 4.7 B 4.8 B 4.9 C 4.10 D 4.11 C 4.12 A 4.13 C & & 4 239

249 i < = 20 5 i% 2 = = 0 6 f2 + f & & & DF a = 8, b = l = 5, m = 4, n = ( 3) 14 if( x! = 0 ) 4.24 : (1 ) if : 240 { long i ; float bonus,bon1,bon2, bon4, bon6,bon10; bon1 = ; bon2 = bon ; bon4 = bon ; bon6 = bon ; bon10 = bon ; printf(: ) ; scanf(%ld, & i) ; if( i < = 1e5 ) bonus = i 0.1 ; else if (i < = 2e5) bonus = bon1 + (i ) ; else if (i < = 4e5) bonus = bon2 + (i ) 0.05 ; else if (i < = 6e5) bonus = bon4 + (i ) 0.03 ; else if (i < = 1e6) else bonus = bon6 + (i ) ; bonus = bon10 + (i ) 0.01 ; printf(: %10.2f \ n, bonus ) ;

250 : : < > : : < > : (2 ) switch : { long i ; float temp,bonus,bon1,bon2, bon4, bon6,bon10; int branch; bon1 = ; bon2 = bon ; bon4 = bon ; bon6 = bon ; bon10 = bon ; printf(: ) ; scanf(%ld, & i) ; temp = i/ ; if( i < = ) branch = 0; else if( temp = = 0) else branch = i/ ; branch = temp; switch( branch) { case 0: bonus = i 0.1 ; break ; : case 1: bonus = bon1 + ( i ) ;break; case 2: case 3: bonus = bon2 + ( i ) 0.05; break; case 4: case 5: bonus = bon4 + ( i ) 0.03; break; case 6: case 7: case 8: case 9: bonus = bon6 + ( i ) ;break; case 10 :bonus = bon10 + (i ) 0.01; printf(: % 10.2f \ n,bonus) ; 241

251 4.25 : : < > : : < > : : < > : { int t, a, b, c, d; 4.26 : printf( : ) ; scanf( % d, % d, % d, % d, & a, &b, &c, &d) ; printf( a = % d, b = % d, c = % d, d = % d \ n, a,b, c,d) ; if(a > b) { t = a ; a = b; b = t ; if(a > c) { t = a ; a = c ; c = t ; if(a > d) { t = a ; a = d; d = t ; if( b > c) { t = b ; b = c; c = t ; if( b > d) { t = b ; b = d; d = t ; if(c > d) : { t = c ; c = d; d = t ; printf(: \ n ) ; printf(% d % d % d % d, a, b, c, d) ; :6,8,1, 4 < > a = 6, b = 8, c = 1, d = 4 : { int day, x1, x2 ; day = 10; x2 = 1; while( day > 0 ) { x1 = ( x2 + 1) 2;

252 x2 = x1 ; day - - ; printf( = % d \ n, x1) ; 4.27 : : = 3070 # define M 1000 { int k0, k1,k2, k3,k4, k5, k6, k7, k8, k9; int i, j, n, s; for (j = 2; j < = M; j + + ) { n = 0 ; s = j; if ( s = = 0) for (i = 1 ; i < j ; i + + ) { if(j% i = = 0) { n + + ; s - = i ; switch( n) { case 1 : k0 = i ; break ; case 2 : k1 = i ; break ; case 3 : k2 = i ; break ; case 4 : k3 = i ; break ; case 5 : k4 = i ; break ; case 6 : k5 = i ; break ; case 7 : k6 = i ; break ; case 8 : k7 = i ; break ; case 9 : k8 = i ; break ; case 10 : k9 = i; break; { printf( % d, :, j) ; if(n > 1 ) printf(% d, % d, k0,k1 ) ; if(n > 2 ) printf(, % d, k2) ; if(n > 3 ) printf(, % d, k3) ; if(n > 4 ) printf(, % d, k4) ; if(n > 5 ) printf(, % d, k5) ; 243

253 if(n > 6 ) printf(, % d, k6) ; if(n > 7 ) printf(, % d, k7) ; if(n > 8 ) printf(, % d, k8) ; if(n > 9 ) printf(, % d, k9) ; printf( \ n ) ; 4.28 : : 6,:1, 2,3 28, :1,2,4, 7,14 496,: 1,2,4,8,16,31,62,124,248 { float k, s1 = 0, s2 = 0,s3 = 0; : for( k = 1 ;k < = 100 ; k + + ) s1 = s1 + k ; for( k = 1 ; k < = 50 ; k + + ) s2 = s2 + k k; for( k = 1 ; k < = 10 ; k + + ) s3 = s3 + 1/ k; printf( = % 8.2f \ n, s1 + s2 + s3) ; = C 5.2 B 5.3 B 5.4 B 5.5 C 5.6 C 5.7 D 5.8 A 5.9 B 5.10 A

254 (2 ) p q st &a[i] [ j] 7 a[i] [i] 8 a[i] [ 3 - i - 1] i < = 1 10 b [j] [ i] = a[i] [j] 11 i < = &a[i] (a + i) 13 i%4 = = 0 14 printf(\ n ) : # include < stdio.h > # include < string.h > { char a[80 ], b, max; int i = 1, j ; printf( Input a string: \ n ) ; gets( a) ; puts( a) ; b = getchar( ) ; max = a[ 0] ; j = 0 ; while(a[ i]! = \ 0 ) { if(max < a[i] ) { max = a[i] ; j = i; i + + ; 245

255 5.23 : for( i = strlen( a) + 1 ; i > j ; i - - ) a[i] = a[i - 1 ] ; a[ i + 1] = b; puts( a) ; : wdhyuks < > a < > wdhyauks # include < stdio.h > # include < stdlib.h > { int i, a[11] ; 5.24 : : for(i = 0 ; i < 10 ; i + + ) a[i] = rand( ) % 20; for(i = 0 ; i < 10 ; i + + ) printf( % 3d, a[i] ) ; printf(\ n ) ; for(i = 10; i > = 4 ; i - - ) a[i] = a[i - 1] ; for(i = 0 ; i < 11 ; i + + ) printf(%3d, a[i] ) ; printf(\ n ) ; { int i, k, min, a[10] ; for (i = 0; i < 10 ; i + + ) { scanf(% d, & a[i] ) ; printf(%4d, a[i] ) ; printf(\ n ) ; min = a[0] ; k = 0 ; for (i = 1; i < 10 ; i + + ) if( min > a[i] ) { min = a[i] ; k = i;

256 printf( : % d \ n, k + 1) ; 5.25 : : < > :6 { int a[ 3] = {5, 19,28; 5.26 : int b[ 5] = {12,24,26,37,48 ; int c[ 10], i = 0, j = 0,k = 0 ; while(i < 3 & & j < 5) if ( a[i] > b[j] ) else : {c[ k ] = b[j] ; k + + ; j + + ; {c[k ] = a[i] ; k + + ; i + + ; while( i < 3 ) {c[ k] = a[i] ; i + + ; k + + ; while ( j < 5 ) {c[ k] = b[ j] ;k + + ;j + + ; for(i = 0 ; i < k; i + + ) printf( % 3d, c[ i] ) ; printf( \ n ) ; # define N 10 # define M 10 { int i, j, k, m,n, flag1,flag2, a[ N] [ M], max, maxj; printf(: ) ; scanf(% d% d, &n, & m) ; printf( % d : \ n, n m) ; for( i = 0; i < n ; i + + ) { for( j = 0; j < m ; j + + ) { scanf(% d, & a[i] [j] ) ; printf(%5d, a[i] [j] ) ; 247

257 flag2 = 0 ; printf( \ n ) ; for (i = 0 ; i < n; i + + ) { max = a[i] [0 ] ; for(j = 0; j < m ; j + + ) if(a[i] [j] > max) { max = a[i] [j] ; maxj = j ; for ( k = 0, flag1 = 1 ; k < n & & flag1; k + + ) if(max > a[ k] [maxj] ) flag1 = 0 ; if ( flag1 ) { printf(% d,% d % d. \ n, i, maxj, max) ; if (! flag2 ) flag2 = 1 ; printf(! \ n ) ; : : :3 4 < > 12 : < > , 3 4. : :3 4 < > 12 : < > ! 5.27 : 248 # include < stdio.h >

258 { int i, j,uppn, lown,dign, span,othn; 5.28 : char text[3 ] [80] ; uppn = lown = dign = span = othn = 0 ; for (i = 0; i < 3; i + + ) { gets( text[i] ) ; for ( j = 0; j < 80 & & text[i] [j]! = \ 0 ; j + + ) : if(text[ i] [ j] > = A& & text[i] [j] < = Z ) uppn + = 1 ; else if( text[i] [j] > = a& & text[i] [j] < = z ) lown + = 1 ; else if( text[i] [j] > = 0& & text[i] [j] < = 9 ) dign + = 1; else if( text[i] [j] = = ) else span + = 1; othn + = 1 ; for (i = 0 ; i < 3 ; i + + ) printf(% s \ n, text[ i] ) ; printf(: % d \ n,uppn) ; printf(: % d \ n, lown) ; printf( : % d \ n, dign) ; printf( : % d \ n, span) ; printf( : % d \ n,othn) ; I am a student.< > < > ASDFG < > I am a student ASDFG :6 :10 :6 :3 :1 { char a[5] = {,,,, ; 249

259 5.29 : int i, j, k; char space = ; for (i = 0 ; i < 5 ; i + + ) { printf( \ n ) ; for (j = 1 ; j < = 3 i; j + + ) printf(% 1c,space) ; for ( k = 0 ; k < 5; k + + ) printf(% 3c, a[ k] ) ; # include < stdio.h > { int i, n; char ch [80 ], tran[ 80 ] ; printf(: ) ; gets(ch) ; printf(\ n : % s, ch) ; i = 0; while ( ch[i]! = \ 0 ) { if( ( ch[i] > = A ) & & (ch[i] < = Z ) ) tran[i] = ch[i] ; else if( ( ch[i] > = a ) & & (ch[i] < = z ) ) n = i ; : else i + + ; tran[i] = ch[i] ; tran[i] = ch[ i] ; printf(\ n : ) ; for(i = 0 ; i < n; i + + ) putchar( tran[i] ) ; : asdfzxcv < > : asdfzxcv : zhwuacxe 250 6

260 6.1 B 6.2 B 6.3 C 6.4 B 6.5 B 6.6 D 6.7 B 6.8 A 6.9 B 6.10 D 6.11 B 6.12 A ,, (1 ) 4 float a = 4, b = 5 a = 4, b = i = 7; j = 6; x = 7 i = 2; j = 7; x = # x = 2 y = 3 z = : x = 4 y = 9 z = x = 2 y = 3 z = 0 double mypow( double x, int y) { int i; double p ; 6.20 : p = 1.0; for(i = 1 ; i < = y; + + i) p = p x; return p; float f2(int n) { if( n = = 1) return 1 ; 251

261 else return(f2 (n - 2 ) n) ; float f1 (int x, int n) { int i; float j = 1 ; 6.21 for(i = 1 ; i < = n; i + + ) j = j x; return j ; # include < stdio.h > { float sum( float, float, int ) ; int n = 20; float n1,n2, t ; n1 = 1 ; n2 = 2 ; t = sum(n1, n2, n) ; printf( t = % f \ n, t) ; float sum( float n1, float n2, int n) { int i ; float n3, t = 0; n3 = n2; for ( i = 1 ; i < = n; i + + ) { t = t + n3/ n1; return t ; : 6.22 n3 = n1 + n2; n1 = n2; n2 = n3; t = # include < stdio.h > { double sum(int a, int n) ; int a, n; double s; printf( Input a & n: \ n ) ; scanf( % d% d, & a, &n) ;

262 printf( a = % d, n = % d \ n, a, n) ; s = sum(a, n) ; printf( s = %.1lf \ n, s) ; double sum(int a, int n) { int i ; double t,s ; s = t = a; for( i = 2 ; i < = n; i + + ) { t = t 10 + a ; s = s + t ; return s ; : 6.23 Input a & n : 3 6 < > a = 3, n = 6 s = # include < math.h > { float root(float) ; float a, x; printf(: \ n ) ; scanf( % f, & a) ; x = root( a) ; printf(%5.2f % 8.5f \ n, a, x) ; float root(float a) { float xn0, xn1; xn0 = a/ 2; xn1 = ( xn0 + a/ xn0)/ 2; do { xn0 = xn1; xn1 = ( xn0 + a/ xn1)/ 2 ; while(fabs( xn0 - xn1 ) > = 1e - 5 ) ; return xn1; : 253

263 6.24 : 2 < > # include < stdio.h > # include < math.h > { int i, a,b, n = 0; for( i = 10; i < = 20 ; i + = 2 ) for( a = 2 ; a < = i/ 2 ; a + + ) if(isprime(a) ) { b = i - a ; if(isprime( b) ) { printf(%5d = % 2d + %3d, i, a,b) ; n + + ; break; printf( \ n ) ; isprime(int c) { int i ; double k; k = (double) sqrt( ( double) c) ; for ( i = 2 ; i < = k; i + + ) if( c%i = = 0 ) return 0 ; return 1; : = = = = = = int alphabetic(char c) { if ( (c > a & & c < = z ) (c > A& & c < = Z ) ) else return( 1) ; return(0 ) ; int longest (char string) { int len = 0,i, length = 0, flag = 1, place,point ;

264 for (i = 0; i < = strlen( string) ; i + + ) { int i ; if (alphabetic( string[i] ) ) else if ( flag) { point = i ; flag = 0; else len + + ; { flag = 1; if(len > length) char line[ 100] ; { length = len ; place = point ; len = 0 ; return( place) ; printf(. \ n ) ; gets( line) ; printf(\ n : ) ; for (i = longest(line) ; alphabetic(line[i] ) ; i + + ) printf(%c, line[ i] ) ; printf(\ n ) ; : I am a student < > : student # include < stdio.h > void convert(int n) { int i ; if( (i = n/ 10 )! = 0) convert(i) ; putchar (n % ) ; { int number; printf(\ n : ) ; 255

265 scanf( % d, & number) ; printf(\ n : ) ; if ( number < 0 ) { putchar ( - ) ; number = - number ; convert( number) ; : 6.27 : < > : { int year, month, day; int days; printf( : \ n ) ; scanf(% d, % d, % d, &year, & month, &day) ; printf(\ n% d % d % d,year, month,day) ; days = sum - day(month,day) ; if(leap(year ) & & month > = 3) days = days + 1 ; printf( % d. \ n, days) ; int day - tab[13 ] = {0,31,28, 31,30,31,30,31,31, 30,31,30,31; int sum - { int i ; day(int month, int day) for (i = 1 ; i < month; i + + ) day + = day - tab[i] ; return (day) ; int leap(int year) { int leap ; : leap = year %4 = = 0 & & year% 100! = 0 year% 400 = = 0; return( leap) ; 256 : 1999,11,26 < >

266 7 7.1 B 7.2 D 7.3 C 7.4 D 7.5 C 7.6 C 7.7 C 7.8 D 7.9 B v = 1 v = ok! 7.18 : # define MOD(a, b) (a% b) { int a,b; 7.16 : printf( Input a, b: ) ; scanf( % d, % d, & a, &b) ; printf( a mod bis: % d \ n, MOD(a,b) ) ; # define swap(x,y) { int t ; t = x ; x = y; y = t ; { int i, a[10],b[ 10] ; 257

267 for (i = 0; i < 10 ; i + + ) scanf(% d, & a[i] ) ; for (i = 0; i < 10 ; i + + ) scanf(% d, &b[i] ) ; for (i = 0; i < 10 ; i + + ) swap(a[ i],b[i] ) ; for (i = 0; i < 10 ; i + + ) printf(% 4d, a[i] ) ; printf(\ n ) ; for (i = 0; i < 10 ; i + + ) printf(% 4d, a[i] ) ; printf(\ n ) ; D 8.2 C 8.3 D 8.4 D 8.5 B 8.6 D 8.7 A 8.8 A 8.9 C 8.10 D i + j 3 5 i + j Franch C Language ef 8.17 : 258

268 { int n1,n2,n3; int pointer - 1, pointer - 2, pointer - 3; printf(n1, n2,n3 : ) ; scanf(% d, % d, % d, &n1, &n2, &n3) ; pointer - 1 = &n1 ; pointer - 2 = &n2 ; pointer - 3 = &n3 ; if (n1 > n2 ) swap( pointer - 1,pointer - 2) ; if (n1 > n3 ) swap( pointer - 1,pointer - 3) ; if (n2 > n3 ) swap( pointer - 2,pointer - 3) ; printf( : % d, % d, % d \ n,n1, n2, n3) ; swap(int p1, int p2 ) { int p; 8.18 : p = p1 ; p1 = p2, p2 = p ; : n1, n2, n3 :34,21,25 < > :21,25,34 { char str1[20], str2 [20 ], str3[ 20 ] ; char swap( ) ; printf( : \ n ) ; scanf(% s,str1 ) ; scanf(% s,str2 ) ; scanf(% s,str3 ) ; if (strcmp( str1, str2) > 0) swap( str1, str2 ) ; if (strcmp( str1, str3) > 0) swap( str1, str3 ) ; if (strcmp( str2, str3) > 0) swap( str2, str3 ) ; printf(: \ n ) ; printf(% s \ n% s \ n% s \ n, str1, str2,str3 ) ; char swap(char p1, char p2) { char p[ 20 ] ; strcpy( p,p1 ) ; strcpy( p1, p2) ; strcpy( p2, p) ; 259

269 8.19 : 8.20 : : : asdfg < > wsed < > abdfr < > : abdfr asdfg wsed # include < stdio.h > # include < string.h > { int a,len; char s[ 50] ; gets( s) ; len = strlen( s) ; a = fun( s, s + len - 1) ; if(a = = 1 ) printf( Yes \ n ) ; else printf( No \ n ) ; fun(char s, char t) { while( t > s & & t = = s ) { s + + ; t - - ; if( t > s) return 0; else return 1; 260 { int a[3 ] [3 ], p, i; printf(33 : \ n ) ; for (i = 0 ; i < 3 ;i + + ) scanf( % d% d % d, &a[i] [0 ], &a[i] [1 ], &a[i] [2 ] ) ; p = & a[0 ] [0 ] ; move( p) ; printf(: \ n ) ; for (i = 0 ; i < 3 ;i + + ) printf( % 3d% 3d %3d \ n, a[i] [0], a[ i] [ 1], a[ i] [ 2] ) ; move (int pointer) { int i, j, t ;

270 for ( i = 0; i < 3; i + + ) for (j = i ; j < 3 ; j + + ) { t = (pointer + 3 i + j) ; ( pointer + 3 i + j) = ( pointer + 3 j + i) ; ( pointer + 3 j + i) = t ; 8.21 : : 33 : < > < > < > : # include < stdio.h > # include < string.h > { int i; char p, str[10] [ 10 ] ; printf(10 : \ n ) ; for (i = 0; i < 10 ; i + + ) scanf(% s,str [i] ) ; p = &str[ 0] [0] ; sort( p) ; printf( : \ n ) ; for (i = 0; i < 10 ;i + + ) printf(% s \ n, str[i] ) ; sort(char p) { int i, j; char s[10], smax, smin ; for (i = 0 ; i < 10 ; i + + ) { smax = p + 10 i ; for (j = i + 1 ; j < 10; j + + ) { smin = p + 10 j; if (strcmp( smax,smin) > 0 ) { strcpy( s, smin) ; 261

271 8.22 : strcpy( smin, smax) ; strcpy( smax, s) ; 8.23 : # include < stdio.h > # include < string.h > { char ch,s[ 50 ] ; int d; gets( s) ; puts( s) ; scanf( % d, &d) ; ch = fun( s, d) ; if( ch ) printf(%c % s, ch, s) ; else printf( Can t find! fun(char s, int d) { char ch; int i, len; len = strlen( s) ; \ n ) ; if( d > = len ) return \ 0 ; else { ch = s[ d] ; for( i = d; i < len; i + + ) s[i] = s[i + 1 ] ; return ch; 262 { int a[ 3] = {5, 19,28; int b[ 5] = {12,24,26,37,48 ; int c[ 10], i, k ; k = add(a, b, c) ; for (i = 0; i < k ; i + + ) printf(% 3d, c[i] ) ; printf(\ n ) ; int add(int a, int b, int c)

272 { int i = 0, j = 0,k = 0 ; while(i < 3 & & j < 5) if ( a[i] > b[j] ) {c[ k] = b[j] ; k + + ; j + + ; else {c[ k] = a[i] ; k + + ; i + + ; while( i < 3 ) {c[ k] = a[i] ; i + + ; k + + ; while ( j < 5 ) {c[ k] = b[j] ;k + + ; j + + ; return k; 8.24 : # include < stdio.h > { int cle = 0, sle = 0,di = 0, wsp = 0,ot = 0, i ; 8.25 : char p, s[20] ; printf(: ) ; for (i = 0; i < 20 ; i + + ) s[i] = 0; i = 0; while ( ( s[i] = getchar( ) )! = \ n ) i + + ; p = &s [0] ; while ( p! = \ n ) { if ( ( A < = p) & & ( p < = Z ) ) + + cle ; : else if ( ( a < = p) & & ( p < = z ) ) + + sle ; else if( p = = ) + + wsp; else if ( ( p < = 9 ) & & ( p > = 0 ) ) + + di; else + + ot ; p + + ; printf(= % d = % d, cle, sle) ; printf( = % d = % d = % d, wsp,di,ot) ; : LET a = < > = 3 = 1 = 1 = 8 = 5 263

273 8.26 : { char month - name[13] = { illgal month, January, February, int n ; March, April,May, June, July, August, September, October, November, December ; printf( : \ n ) ; scanf( % d, & n) ; if ( (n < = 12) & & (n > = 1 ) ) else printf( % d % s.,n, (month - name + n) ) ; printf( % d., n) ; # include < stdio.h > # include < string.h > { int m ; char str1[ 80], str2[80] ; printf( Input a string: \ n ) ; gets( str2) ; printf( Input m : \ n ) ; scanf( % d, & m) ; if( strlen( str2) < m) printf( Err input! else { copystr( str1,str2, m) ; printf( Result is : % s \ n,str1 ) ; copystr(char p1, char p2, int m) { int n = 0 ; while( n < m - 1) { p2 + + ; n + + ; while( p2! = \ 0 ) { p1 = p2 ; p1 + + ; p2 + + ; p1 = \ 0 ; \ n ) ; D 264

274 9.2 C 9.3 B 9.4 A 9.5 D 9.6 A 9.7 B 9.8 C 9.9 A 9.10 C 9.11 D Zhang p = stud 5 p - > name ( p).name , sizeof( bt) , : typedef st ruct slist { int data ; SLIST ; struct slist next ; SLIST creat - slist( ) { int a ; SLIST h, s, r ; h = ( SLIST ) malloc( sizeof( SLIST) ) ; r = h; scanf(% d, &a) ; while( a! = 0) { s = ( SLIST )malloc(sizeof( SLIST) ) ; s - > data = a ; r - > next = s; r = s; scanf( % d, & a) ; 265

275 print - r - > next = return h ; \ 0 ; slist( SLIST head) { SLIST p ; p = head - > next ; if( p = = \ 0 ) printf( Linklist is null! else { printf( head ) ; do { printf(- - > % d, p - > data) ; p = p - > next ; while( p! = \ 0 ) ; printf(- int sum( SLIST h ) { int s = 0; 9.19 : 9.20 : SLIST p = h - > next ; - > end \ n ) ; \ n ) ; while( p! = \ 0) { s + = p - > data ; p = p - > next ; return s ; { int s ; SLIST head; head = creat - slist( ) ; print - slist( head) ; s = sum( head) ; printf( s = % d \ n, s) ; 9.18 sum( SLIST h) s + = p - > data ; s + + ; 266 typedef st ruct slist { int data ; struct slist next ; SLIST ; SLIST creat - slist( ) { int a ;

276 SLIST h, s, r ; h = ( SLIST ) malloc( sizeof( SLIST) ) ; r = h; scanf(% d, &a) ; while(a! = 0) { s = ( SLIST )malloc(sizeof( SLIST) ) ; s - > data = a ; r - > next = s ; r = s; scanf( % d, & a) ; r - > next = \ 0 ; return h ; print - slist( SLIST head) { SLIST p; p = head - > next ; if( p = = \ 0 ) printf( Linklist is null! else { printf( head ) ; do { printf(- - > % d, p - > data) ; p = p - > next ; while( p! = \ 0 ) ; printf(- - > end \ n ) ; SLIST max( SLIST h) { int m = ; SLIST q, p; p = q = h - > next ; while( p! = \ 0) \ n ) ; { if( m < p - > data ) { m = p - > data ; q = p ; return q; p = p - > next ; { SLIST head, p; head = creat - slist( ) ; print - slist( head) ; p = max ( head) ; 267

277 printf( max = % d \ n, p - > data) ; 9.21 : 268 typedef st ruct slist { long num ; float score[3 ] ; struct slist next ; SLIST ; SLIST creat - slist( ) { int i ; print - long a; float s [3] ; SLIST h, w, r; h = ( SLIST ) malloc( sizeof( SLIST) ) ; r = h; scanf(%ld, % f, % f, % f, & a, &s[ 0], &s[ 1], &s [2] ) ; while( a! = 0) { w = ( SLIST ) malloc( sizeof( SLIST) ) ; w - > num = a ; for(i = 0; i < 3; i + + ) w - > score[i] = s[i] ; r - > next = w ; r = w ; scanf( % ld, % f, % f, % f, &a, & s[0 ], &s[1 ], &s[ 2] ) ; r - > next = \ 0 ; return h ; slist( SLIST head) { SLIST p ; p = head - > next ; if( p = = \ 0 ) printf( Linklist is null! else { printf( head ) ; do { printf(- - > %f,p - > score[ 1] ) ; p = p - > next ; while( p! = \ 0 ) ; printf(- fun( SLIST h) - > end \ n ) ; \ n ) ;

278 { int i = 1; SLIST q, p = h - > next ; q = h; 9.22 : while(i < 3 ) { p = p - > next ; i + + ; p - > score[1] = 90 ; { int s ; SLIST head; head = creat - slist( ) ; print - slist( head) ; fun( head) ; print - slist( head) ; # include < stdio.h > typedef st ruct slist { long num ; float score[3] ; struct slist next ; SLIST ; SLIST creat - slist( ) { int i ; long a; float s [3] ; SLIST h, w, r; h = ( SLIST ) malloc( sizeof( SLIST) ) ; r = h; scanf(%ld, % f, % f, % f, & a, &s[ 0], &s[ 1], &s [2] ) ; while( a! = 0) { w = ( SLIST ) malloc( sizeof( SLIST) ) ; w - > num = a ; for(i = 0; i < 3; i + + ) w - > score[i] = s[i] ; r - > next = w ; r = w ; scanf( % ld, % f, % f, % f, &a, & s[0 ], &s[1 ], &s[ 2] ) ; r - > next = \ 0 ; return h ; fun( SLIST h) 269

279 9.23 : { int i ; float sum, ave; SLIST q, p = h - > next ; q = h; while(p! = NULL) { sum = 0 ; { int s ; for (i = 0; i < 3 ; i + + ) sum = sum + p - > score[i] ; ave = sum/ 3 ; printf( ave = % f \ n, ave) ; p = p - > next ; SLIST head; head = creat - slist( ) ; fun( head) ; typedef st ruct node { int data ; struct next ; linklist ; invert(linklist head) { linklist p, q; p = head - > next ; if ( p! = NULL) { head - > next = NULL ; do { q = p - > next ; p - > next = head - > next ; head - > next = p; p = q; while(p! = NULL) ;

280 10.1 B 10.2 D 10.3 C 10.4 A a a : { unsigned a ; int n1, n2; printf( a: ) ; scanf( % o, &a) ; printf( n1,n2: ) ; scanf( % d, % d, &n1, &n2) ; printf( % o \ n,getbits(a, n1-1,n2 ) ) ; getbits( unsigned value, int n1, int n2 ) { unsigned z; z = 0; z = (z > > n1) &(z < < (16 - n2 ) ) ; z = value& z; z = z > > (16 - n2 ) ; return z; 271

281 : a : < > n1,n2 :5,8 < > : { unsigned int a ; printf( : ) ; scanf( % o, &a) ; printf( : % o \ n,getbits(a) ) ; getbits( unsigned int value) { int i, j, m,n ; : unsigned int z, a, q; z = 0 ; for( i = 1 ; i < = 15 ; i + = 2) { q = 1 ; return z; : for (j = 1 ; j < = ( 16 - i - 1)/ 2; j + + ) q = q 2 ; a = value > > ( 16 - i) ; a = a < < 15 ; a = a > > 15 ; z = z + a q; : < > : 263 : < > : { unsigned a ; int n; printf(: ) ; scanf(% o, & a) ; printf(: ) ; scanf(% d, &n) ;

282 if( n > 0 ) { moveright(a, n) ; else printf( : % o \ n, moveright( a, n) ) ; { n = - n; moveleft(a,n) ; printf( : %o \ n, moveleft(a,n) ) ; moverigh t(unsigned value, int n) { unsigned z; z = (value > > n) (value < < (16 - n ) ) ; return(z) ; moveleft( unsigned value, int n) { unsigned z; : z = (value > > ( 16 - n) ) ( value < < n) ; return z; : : < > : 4 < > : : < > : - 4 < > : { unsigned int a ; unsigned int getbits ( ) ; printf(: ) ; scanf(% o, & a) ; printf(: % o \ n, getbits(a) ) ; unsigned int getbits( unsigned in t value) { unsigned int z ; z = value& ; if(z = = ) z = value + 1 ; else z = value ; 273

283 return z; : : 2345 < > :2345 : < > : C 11.2 C 11.3 C 11.4 D 11.5 C 11.6 D 11.7 C 11.8 B 11.9 A F ILE fp ASCII NULL stdout 7 stderr r 9 fgetc( fp) 10 count FILE f 12 sizeof( struct rec) 13 r.num, r.total

284 fp1, fp2 20 rewind( fp1 ) 21 getc( fp1 ), fp fp 23 fp, i sizeof( struct student - type), 0 24 & stud [i] : : # include < stdio.h > { FILE fp; char str[100], filename[10] ; int i = 0; if ( ( fp = fopen( test,w ) ) = = NULL) { printf(? \ n ) ; exit(0 ) ; printf(?: \ n ) ; getchar ( ) ; while(str[ i]! =! ) { if( str[i] > = a & & str[i] < = z ) str[i] = str[i] - 32 ; fputc( str[i], fp) ; i + + ; fclose( fp) ; fp = fopen( test, r ) ; fgts( str, strlen( str) + 1, fp) ; printf(% s \ n, str) ;fclose(fp) ; # include < stdio.h > struct student { char num[6 ] ; char name[ 8] ; int score[3 ] ; 275

285 fioat avr; stu[ 5] ; { int i, j, sum ; : FILE fp; for( i = 0 ; i < 5; i + + ) { printf( \ n?% d?: \ n, i + 1 ) ; printf(?: ) ; scanf( % s, stu[ i],num) ; printf(?: ) ; scanf% s,stu[i].name) ; sum = 0 ; for (j = 0; j < 3 ; j + + ) { printf?% d., j + 1) ; scanf(% d, & stu[ i].score[j] ) ; sum + = stu[ i].score[j] ; stu[i].avr = sum/ 3.0; fp = fopen( stud, w ) ; for (i = 0 ; i < 5 ; i + + ) if ( fwrite( &stu[i], sizeof( struct student),1, fp)! = 1) fclose( fp) ; printf( file write error \ n ) ; 276 # include < stdio.h > struct emplo { char num[ 6] ; char name[8 ] ; char sex[3 ] ; int age ; char add[20 ] ; int salar; char state[8] ; char class [4] ; em[ 10] ; struct emp { char na[ 8] ; int sal ;

286 em - ease[ 10] ; { FILE fp1, fp2 ; int i, j ; if ( ( fp1 = fopen( emploee, r ) ) = = NULL) { printf( ) ; exit(0) ; for (i = 0; fread( & em[i], sizeof( struct emplo),1, fp1)! = 0 ; i + + ) { printf (\ n% 8s% 8s% 6s% 6d %8s% 6d% 8s% 8s, em[i].num, em[i].name, em[i].sex, em[i].age, em[i].add, em[i].salar, em[i].state, em[i].class) ; strcpy(em - ease[i].na, em[i].name) ; em - ease[i].sal = em[i].salar; printf( \ n \ n ) ; fp2 = fopen( emp - for(j = 0 ; j < i ; j + + ) sa, w ) ; { fwrite( & em - ease[j], sizeof( struct emp),1, fp2) ; printf(\ n % 12s %6d, em - ease[j].na, em - ease[j].sal) ; printf( \ n ) ; fclose (fp1 ) ; fclose( fp2 ) ; : 010 a1 a2 25 a3 125 a4 a5 011 b1 b2 40 b3 89 b4 b5 012 c1 c2 35 c3 131 c4 c5 013 d1 d2 50 d3 155 d4 d5 a1 125 b1 89 c1 131 d1 155 : emploee,, emp - sa emploee: # include < stdio.h > 277

287 st ruct emplo { char num[6 ] ; char name[ 8] ; char sex [3] ; in t age; char add[20] ; int salar ; char state[8 ] ; char class[4 ] ; em[ 10] ; { FILE fp; int i, j ; printf(? \ n ) ; for(i = 0 ; i < 4; i + + ) {scanf(% s % s % s % d % s % d % s % s, em[i].num, em[i].name, em[i].sex, & em[i].age, em[i].add, & em[ i].salar, em[i].state, em[i].class) ; printf(% s % s % s % d % s % d % s % s \ n, em[i].num, em[i].name, em[i].sex, em[i].age, em[i].add, em[i].salar, em[i].state, em[i].class ) ; fp = fopen( emploee, w ) ; for (i = 0; i < 4; i + + ) fwrite( & em[i],sizeof( struct emplo),1, fp) ; fclose(fp) ; : 010 a1 a2 25 a3 125 a4 a5 < > 011 b1 b2 40 b3 89 b4 b5 < > 012 c1 c2 35 c3 131 c4 c5 < > 013 d1 d2 50 d3 155 d4 d5 < > : 278 # include < stdio.h > # include < string.h > struct emplo { char name[8 ] ; int salar; emp[20], tmp ; { FILE fp; int i, j, n, flag;

288 char na[ 8] ; int sa ; if ( ( fp = fopen( emp - sa, r + ) ) = = NULL) { printf( ) ; exit( 0) ; for( i = 0 ; fread( & emp[ i],sizeof( struct emplo),1, fp)! = 0; i + + ) printf(\ n% 8s % 6d, emp[i].name, emp[i].salar) ; fclose( fp) ; n = i ; printf(\ n : ) ; scanf(% s,na) ; for (flag = 1, i = 0; flag & & i < n; i + + ) { if( strcmp( na, emp[ i].name) = = 0) { for (j = i; j < n - 1; j + + ) { strcpy(emp[ j].name, emp[j + 1 ].name) ; flag = 0; if(! flag) n - = 1; emp[j].salar = emp[j + 1 ].salar; else printf( \ n! ) ; printf(\ n : \ n ) ; fp = fopen( emp - sa, w ) ; for (i = 0; i < n ; i + + ) fwrite( & emp[i],sizeof(struct emplo), 1,fp) ; fclose(fp) ; fp = fopen( emp - sa, r ) ; for(i = 0; fread( &emp[i], sizeof( struct emplo),1, fp)! = 0; i + + ) printf( \ n %8s %6d, emp[i].name, emp[i].salar) ; fclose(fp) ; 279

289 [1].C ( ). :,1999 [2].( C ). :,1995 [3].C, :,1992 [4].C, :,1998 [5] Waite M, Prata S.. C. :,1994 [6] Schildt H..C (), :, 1994 [7],(1998 ), :,1998 [8]. C. :,

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7 1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7-80097 - 564-9 /TP 8 : 10. 00 ,,,, 1994 NCRE,,, ( ),,,,,

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: [email protected] 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

C

C C 2017 3 14 1. 2. 3. 4. 2/95 C 1. 3/95 C I 1 // talkback.c: 2 #include 3 #include 4 #define DENSITY 62.4 5 int main(void) 6 { 7 float weight, volume; 8 int size; 9 unsigned long letters;

More information

_汪_文前新ok[3.1].doc

_汪_文前新ok[3.1].doc 普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

プログラムの設計と実現II

プログラムの設計と実現II UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

C C

C C C C 2017 3 8 1. 2. 3. 4. char 5. 2/101 C 1. 3/101 C C = 5 (F 32). 9 F C 4/101 C 1 // fal2cel.c: Convert Fah temperature to Cel temperature 2 #include 3 int main(void) 4 { 5 float fah, cel; 6 printf("please

More information

C, Win-TC Turbo C,, C, C,,,, C C, : Win-TC C, 23,,, 15,, C Turbo C Win-TC Turbo C,,,, 2005 1 W in -TC 1 Win-TC 1 1. Win-TC 1 2. Win-TC 1 3. Win-TC 1 2 Win-TC 3 1. 3 2. 3 3. 4 4. 4 5. 4 6. 4 7. 5 8. 5 9.

More information

C/C++ - 字符串与字符串函数

C/C++ - 字符串与字符串函数 C/C++ Table of contents 1. 2. 3. 4. 1 char C 2 char greeting [50] = " How " " are " " you?"; char greeting [50] = " How are you?"; 3 printf ("\" Ready, go!\" exclaimed John."); " Ready, go!" exclaimed

More information

Ps22Pdf

Ps22Pdf C ( CIP) C /. :, 2001. 7 21 ISBN 7-5624 -2355-5. C........ C. TP312 CIP ( 2001 ) 034496 C * * : 7871092 1 /16 : 14. 25 : 356 20017 1 20017 1 : 1 6 000 ISBN 7-5624-2355-5 / TP311 : 21. 00 C, C,,,, C,, (

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: [email protected] 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

untitled

untitled Introduction to Programming ( 數 ) Lecture 3 Spring 2005 March 4, 2005 Lecture 2 Outline 數 料 If if 狀 if 2 (Standard Output, stdout): 料. ((Standard Input, stdin): 料. 類 數 數 數 說 printf 見 數 puts 串 數 putchar

More information

C

C C 14 2017 5 31 1. 2. 3. 4. 5. 2/101 C 1. ( ) 4/101 C C ASCII ASCII ASCII 5/101 C 10000 00100111 00010000 ASCII 10000 31H 30H 30H 30H 30H 1 0 0 0 0 0 ASCII 6/101 C 7/101 C ( ) ( ) 8/101 C UNIX ANSI C 9/101

More information

C

C C 2017 4 1 1. 2. while 3. 4. 5. for 6. 2/161 C 7. 8. (do while) 9. 10. (nested loop) 11. 12. 3/161 C 1. I 1 // summing.c: 2 #include 3 int main(void) 4 { 5 long num; 6 long sum = 0L; 7 int status;

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

Microsoft Word - chap13.doc

Microsoft Word - chap13.doc ï FILE dã Ä o rô qî ô Ö ƒù å o ô ÃÓ FILE Ã Ù Ö o v-> ª w ï FILE d wã +1 ~ c:\temp w Õx test.dat Ã Û vä à n ïw à test.dat 13-2a /* File name: ex13-2a.c */ #include char ch; fptr = fopen("c:\\temp\\test.dat",

More information

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

Microsoft Word - CPE考生使用手冊160524.docx

Microsoft Word - CPE考生使用手冊160524.docx 大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該

More information

Microsoft PowerPoint - 20-string-s.pptx

Microsoft PowerPoint - 20-string-s.pptx String 1 String/ 1.: char s1[10]; char *s2; char s3[] = "Chan Tai Man"; char s4[20] = "Chan Siu Ming"; char s5[]={'h','e','l','l','o','\0'; 0 1 2 3 4 5 6 7 8 9 10 11 12 s3 C h a n T a i \0 M a n \0 printf

More information

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 float candy [ 365]; char code [12]; int states [50]; 2 int array [6] = {1, 2, 4, 6, 8, 10}; 3 // day_mon1.c: # include # define MONTHS 12 int

More information

1 2 / 3 1 A (2-1) (2-2) A4 6 A4 7 A4 8 A4 9 A ( () 4 A4, A4 7 ) 1 (2-1) (2-2) ()

1 2 / 3 1 A (2-1) (2-2) A4 6 A4 7 A4 8 A4 9 A ( () 4 A4, A4 7 ) 1 (2-1) (2-2) () (39mm E-Mail ( )( ), : : 1 1 ( ) 2 2 ( ) 29mm) WSK ( 1 2 / 3 1 A4 2 1 3 (2-1) 2-1 4 (2-2) 2-2 5 A4 6 A4 7 A4 8 A4 9 A4 10 11 ( () 4 A4, 5 6 7 8 A4 7 ) 1 (2-1) (2-2) () 1 2 (2-1) 3 (2-2) 4 5 6 7 (8 ) 9

More information

4 / ( / / 5 / / ( / 6 ( / / 7 1 2 / 3 ( 4 ( 2003 8 ( 2

4 / ( / / 5 / / ( / 6 ( / / 7 1 2 / 3 ( 4 ( 2003 8 ( 2 : / ( 6 (2003 8 : ( 1 ( ( / / (,, ( ( - ( - (39mm 29mm 2 ( 1 2 3-6 3 6-24 6-48 12-24 8-12 WSK / WSK WSK 1 4 / ( / / 5 / / ( / 6 ( / / 7 1 2 / 3 ( 4 ( 2003 8 ( 2 9 5 ( 10 3 11 / (600 4 5 AA 710 AB 720 730

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

More information

四川省普通高等学校

四川省普通高等学校 四 川 省 普 通 高 等 学 校 计 算 机 应 用 知 识 和 能 力 等 级 考 试 考 试 大 纲 (2013 年 试 行 版 ) 四 川 省 教 育 厅 计 算 机 等 级 考 试 中 心 2013 年 1 月 目 录 一 级 考 试 大 纲 1 二 级 考 试 大 纲 6 程 序 设 计 公 共 基 础 知 识 6 BASIC 语 言 程 序 设 计 (Visual Basic) 9

More information

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf(%d, &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf(% 2013 ( 28 ) ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 10 B 1 C 1 D 5 E 5 F 1 G II 5 H 30 1 2013 C 1 #include 2 int main(void) 3

More information

b1²Ä¤@³¹¼Æ»P§¤¼Ð¨t

b1²Ä¤@³¹¼Æ»P§¤¼Ð¨t 第 一 章 數 與 坐 標 系 大 學 聯 考 試 題 與 推 薦 甄 選 試 題 第 一 類 大 學 入 學 甄 試 試 題 評 量 1. 下 列 何 者 是 2 100 除 以 10 的 餘 數? (1) 0 (2) 2 (3) 4 (4) 6 (5) 8 88 年 2. 一 個 正 三 角 形 的 面 積 為 36, 今 截 去 三 個 角 ( 如 右 圖 ), 使 成 為 正 六 邊 形,

More information

CHAPTER VC#

CHAPTER VC# 1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8 Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2 2-1 2-1.1 2-1 1 10 10!(1 10) 2-3 Visual C# 2008 10! 32767 short( )

More information

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf (%d, & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf (%d %d 2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,

More information

( ) Wuhan University

( ) Wuhan University Email: huangzh@whueducn, 47 Wuhan Univesity i L A TEX,, : http://affwhueducn/huangzh/ 8 4 49 7 ii : : 4 ; 8 a b c ; a b c 4 4 8 a b c b c a ; c a b x y x + y y x + y x x + y x y 4 + + 8 8 4 4 + 8 + 6 4

More information

( ) : ( ) (CIP) /.. :,003. () ISBN O4 44 CIP (00) : : 7 : 7007 : (09 ) : : :850 mm 68 mm / 3 :0.5 :60 :00 0

( ) : ( ) (CIP) /.. :,003. () ISBN O4 44 CIP (00) : : 7 : 7007 : (09 ) :   : :850 mm 68 mm / 3 :0.5 :60 :00 0 ( ) ( ) : ( ) (CIP) /.. :,003. () ISBN 7 56 448 0.... O4 44 CIP (00) 007344 : : 7 : 7007 : (09 )8493844 : www.nwpup.com : :850 mm 68 mm / 3 :0.5 :60 :00 003 3 :0 006 000 :3: 00 00, ( ),,,,,,,, 003 8 (

More information

第3章.doc

第3章.doc 3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: [email protected] 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 [email protected] C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

1 32 a + b a + b 2 2 a b a b 2 2 2 4a 12a + 9 a 6 2 4 a 12a + 9 a 6 ( 2a 3) 2 a 6 3 1 2 4 + 2 4 8 + 3 6 12 + 1 3 9 + 2 6 18+ 3 9 27 + 1 10 1 10 ax + by = 2 cx 7y = 8 1 2 1 4 1 8 1

More information

3.1 num = 3 ch = 'C' 2

3.1 num = 3 ch = 'C' 2 Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:

More information

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月 高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月 电 子 教 案 P1 2 978-7-111-27081-2 计 算 机 应 用 基 础 ( 第 2

More information

Microsoft Word - 09.數學136-281.docx

Microsoft Word - 09.數學136-281.docx 136. 計 算 梯 型 面 積 (1 分 ) 請 以 JAVA 運 算 式 計 算 下 面 梯 形 面 積, 並 輸 出 面 積 結 果 梯 形 面 積 公 式 為 :( 上 底 + 下 底 ) 高 2 每 一 組 依 序 分 別 輸 入 梯 形 的 上 底 下 底 及 高 的 整 數 輸 出 梯 形 面 積 輸 入 輸 出 94 190 120 99 54 47 137. 計 算 三 角 形 面

More information

Ps22Pdf

Ps22Pdf (3 ) ,,, ;,, (CIP) /. 3. :, 003. 11 () ISBN 75610994.... TB301 CIP (000) 75084 : : 17, :71007 :09-8493844 : www.nwpup.com : : 787 mm1 09 mm 1/ 16 : 1.5 : 509 : 1997 10 1 003 11 3 5 : 15 000 : 7.00 : (,,,

More information

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha CYPOK CYPOK 1 UltraEdit Project-->Install Language Tool: Language Suite----->hi-tech picc Tool Name ---->PICC Compiler Executable ---->c:hi-picinpicc.exe ( Command-line Project-->New Project-->File Name--->myc

More information

高二立體幾何

高二立體幾何 008 / 009 學 年 教 學 設 計 獎 勵 計 劃 高 二 立 體 幾 何 參 選 編 號 :C00 學 科 名 稱 : 適 用 程 度 : 高 二 簡 介 一 本 教 學 設 計 的 目 的 高 中 立 體 幾 何 的 學 習 是 學 生 較 難 理 解 而 又 非 常 重 要 的 一 個 部 分, 也 是 高 中 教 學 中 較 難 講 授 的 一 個 部 分. 像 國 內 的 聯 校

More information

Ps22Pdf

Ps22Pdf 1, : ( ),?, :,,,, ( ), 1 180,, ( ) 1 1,, 2 180 ;,, 3 180 ;, n ( n - 2 ),, ( n - 2) 180 1 1, : ( ),.,, 2, (, ) 1 , 3 x + y = 14, 2 x - y = 6 : 1 ( ) : + 5 x = 20, x = 4 x = 4 y = 2, x = 4, y = 2 2 ( ) :

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

Ps22Pdf

Ps22Pdf ( ) 158,,,,,, ( CIP) /. :, 1996. 12 ISBN 7 302 02353 0... :. F275 CIP ( 96) 20860 : ( :, 100084) : : : 850 1168 1/ 32 : 13. 25 : 344 : 1996 12 1 1996 12 1 : ISBN 7 302 02353 0/ F 130 : 0001 5000 : 16.

More information

Microsoft Word - C-pgm-ws2010.doc

Microsoft Word - C-pgm-ws2010.doc Information and Communication Technology 資訊與通訊科技 Loops (while/for) C 廻路 姓名 : 班別 : ( ) CS C Programming #1 Functions 函數 : 1 若 n=14, 求以下表示式的值 Expressions 表示式 Value 值 Expressions 表示式 Value 值 A 20 2 * (n /

More information

数 学 高 分 的 展 望 一 管 理 类 联 考 分 析 第 一 篇 大 纲 解 析 篇 编 写 : 孙 华 明 1 综 合 能 力 考 试 时 间 :014 年 1 月 4 日 上 午 8:30~11:30 分 值 分 配 : 数 学 :75 分 逻 辑 :60 分 作 文 :65 分 ; 总

数 学 高 分 的 展 望 一 管 理 类 联 考 分 析 第 一 篇 大 纲 解 析 篇 编 写 : 孙 华 明 1 综 合 能 力 考 试 时 间 :014 年 1 月 4 日 上 午 8:30~11:30 分 值 分 配 : 数 学 :75 分 逻 辑 :60 分 作 文 :65 分 ; 总 目 录 数 学 高 分 的 展 望... 1 第 一 篇 大 纲 解 析 篇... 1 一 管 理 类 联 考 分 析... 1 二 最 新 大 纲 解 析... 1 三 考 前 复 习 资 料 及 方 法... 第 二 篇 总 结 篇... 4 1 应 用 题 考 点 总 结 与 技 巧 归 纳... 4 代 数 模 块 题 型 归 纳 及 考 点 总 结... 9 3 数 列 模 块 题 型 归

More information

科学计算的语言-FORTRAN95

科学计算的语言-FORTRAN95 科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造

More information

-2 4 - cr 5 - 15 3 5 ph 6.5-8.5 () 450 mg/l 0.3 mg/l 0.1 mg/l 1.0 mg/l 1.0 mg/l () 0.002 mg/l 0.3 mg/l 250 mg/l 250 mg/l 1000 mg/l 1.0 mg/l 0.05 mg/l 0.05 mg/l 0.01 mg/l 0.001 mg/l 0.01 mg/l () 0.05 mg/l

More information

Ps22Pdf

Ps22Pdf ) ,,, :,,,,,,, ( CIP) /. :, 2001. 9 ISBN 7-5624-2368-7.......... TU311 CIP ( 2001) 061075 ( ) : : : : * : : 174 ( A ) : 400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / / www. cqup.

More information

[改訂新版]C言語による標準アルゴリズム事典

[改訂新版]C言語による標準アルゴリズム事典 iii C 1991 SEND + MORE = MONEY C 100 2003 Java 2003 27 PC-9800 C BMP SVG EPS BMPSVG WindowsMacLinux Web iv int main() int main(void) EXIT_SUCCESS 0 https://github.com/okumuralab/ algo-c TEX TEX PDF PDF

More information

tbjx0033ZW.PDF

tbjx0033ZW.PDF 1998 20 2000 6 1949 4 20 4 21 22 2 22 1 2 1 Ad hu Bqi n qi n C s s i Dqi n ji n 2 A B C D 22 22 20 24 30 21 5 35 2/3 23 21 (11) 35 (12) (13) 23 (14) 21 22 (15) 1 A B C D 2 A B C D 3 A B C D 4 A 20 B

More information

: : : ( CIP ) : ( ) /. :, ISBN :. G7. 4 CIP ( 00 ) 005 : : ( ) : : ( 0 : 0004) : : : / 6 : 7 ( ) : 408 () : 00

: : : ( CIP ) : ( ) /. :, ISBN :. G7. 4 CIP ( 00 ) 005 : : ( ) : : ( 0 : 0004) : : : / 6 : 7 ( ) : 408 () : 00 () ( ) ( : ) : : : ( CIP ) : ( ) /. :, 00. 7 ISBN 7-8008 - 958-8... :. G7. 4 CIP ( 00 ) 005 : : ( ) : : ( 0 : 0004) : : 00 7 00 7 : 78709 / 6 : 7 ( ) : 408 () : 000 : ISBN 7-8008 - 958-8/ G89 : 9 98. 00

More information

Microsoft Word - 实验习题N.doc

Microsoft Word - 实验习题N.doc 数 学 实 验 实 验 练 习 题 汇 总 实 验 数 学 建 模 初 步 实 验 目 的 通 过 解 决 简 化 的 实 际 问 题 学 习 初 步 的 数 学 建 模 方 法, 培 养 建 模 意 识 实 验 内 容. 怎 样 解 决 下 面 的 实 际 问 题? 包 括 需 要 哪 些 数 据 资 料, 要 做 些 什 么 观 察 试 验 以 及 建 立 什 么 样 的 数 学 模 型 等 :

More information

50~56 I1. 1 A 2 3 I2. I2a. 1 2 3 4 5 ( ) I2b. 1 2 3 I2b1. 4 5 ( ) I3. 11 12 02 ( ) 1 2 (24 ) A1. 0 1 A2 A1a. ( ) A2. ( ) () () ( ) ------------------------------------------------------------------------------------------

More information

《C语言程序设计》教材习题参考答案

《C语言程序设计》教材习题参考答案 教 材 名 称 : C 语 言 程 序 设 计 ( 第 1 版 ) 黄 保 和 江 弋 编 著 清 华 大 学 出 版 社 ISBN: 978-7-302-13599-9, 红 色 封 面 答 案 制 作 时 间 :2011 年 2 月 -5 月 一 思 考 题 1 常 量 和 变 量 有 什 么 区 别? 它 们 分 别 是 如 何 定 义 的? 常 量 是 指 在 C 程 序 运 行 过 程 中

More information

Ps22Pdf

Ps22Pdf ( ) ( 150 ) 25 15 20 40 ( 25, 1, 25 ), 1. A. B. C. D. 2. A. B. C. D. 3., J = 1 H = 1 ( A B, J', J, H ) A. A = B = 1, J' =0 B. A = B = J' =1 C. A = J' =1, B =0 D. B = J' = 1, A = 0 4. AB + AB A. AB B. AB

More information

( CIP).:,3.7 ISBN TB CIP (3) ( ) ISBN O78 : 3.

( CIP).:,3.7 ISBN TB CIP (3) ( ) ISBN O78 : 3. ( CIP).:,3.7 ISBN 7 568 383 3.......... TB CIP (3) 334 3 37 ( ) 64536 www.hdlgpress.com.c 7879 6 9.75 479 3 7 3 7 45 ISBN 7 568 383 3O78 : 3. 995,.,.,.,. :,,,,.. :,,,,,,.,,,,.,,. ,,.,,,.,,,.,,,,.,.,,,

More information

桃園縣南美國民小學102學年度學校課程計畫

桃園縣南美國民小學102學年度學校課程計畫 桃 園 縣 南 美 國 民 小 學 02 學 年 度 學 校 課 程 計 畫 壹 依 據 一 教 部 國 民 中 小 學 九 年 一 貫 課 程 綱 要 (92.0.5 台 國 字 第 092006026 號 函 ) 二 95.05.24 台 國 ( 二 ) 字 第 0950075748B 號 令 修 正 第 伍 點 ( 學 習 領 域 ) 第 陸 點 ( 實 施 要 點 ) 三 教 部 97 年

More information

. (A) (B) (C) A (D) (E). (A)(B)(C)(D)(E) A

. (A) (B) (C) A (D) (E). (A)(B)(C)(D)(E) A . () () () () () (A) (B) (C) B (D) (E). (A) (B) (C) E (D) (E) (A) (B) (C) (D). () () () () E (A) (B) (C) (D) (E). C (A) (B) (C) (D) (E). (A) (B) (C) (D) D (E). () - () - () - () - () - D (A) (B) (C) (D)

More information

Microsoft Word - 烘焙食品乙級第二部份 doc

Microsoft Word - 烘焙食品乙級第二部份 doc 烘 焙 食 品 乙 級 技 術 士 技 能 檢 定 術 科 參 考 資 料 試 題 編 號 :077-900201-3 審 定 日 期 : 年 月 日 修 訂 日 期 :96 年 7 月 1 日 97 年 1 月 30 日 97 年 10 月 27 日 98 年 6 月 20 日 98 年 12 月 17 日 99 年 08 月 20 日 烘 焙 食 品 乙 級 技 術 士 技 能 檢 定 術 科

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer [email protected] 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information