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 >

新版 明解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: feis.tw@gmail.com 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: feis.tw@gmail.com 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

untitled

untitled CHAPTER 02 2 CHAPTER 2-1 2-4 2-2 2-5 2-3 2-6 2-1 2-1-1 2-2 02 int A[3] = {10, 20, 30; A[0] 10 A[1] 20 A[2] 30 int *pa[3], A[3]; C 3 pa pa[0]pa[1]pa[2] 3 A A[0]A[1]A[2] 3 A A[0] A + i A[i] A + i &A[i]*(A

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

untitled

untitled 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8 1-1-1 C int main(void){ int x,y,z; int sum=0; double avg=0.0; scanf("%d",&x) ; scanf("%d",&y) ; scanf("%d",&z) ; sum=x+y+z ; avg=sum/3.0; printf("%f\n",avg); system("pause");

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

untitled

untitled 串 串 例 : char ch= a ; char str[]= Hello ; 串 列 ch=getchar(); scanf( %c,&ch); 串 gets(str) scanf( %s,str); 8-1 數 ASCII 例 : char ch= A ; printf( %d,ch); // 65 A ascii =0x41 printf( %c,ch); // A 例 : char ch;

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

C/C++ - 结构体、共用体、枚举体

C/C++ - 结构体、共用体、枚举体 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 C C (struct) C 2 C C (struct) C 2 i // book.c: # include < stdio.h> # define MAX_ TITLE 41 # define MAX_ AUTHOR 31 struct book { char title [ MAX_ TITLE

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

2015年计算机二级(C语言)模拟试题及答案(四)

2015年计算机二级(C语言)模拟试题及答案(四) 2016 年 计 算 机 二 级 (C 语 言 ) 模 拟 试 题 及 答 案 (4) 一 填 空 题 1 C 语 言 中 基 本 的 数 据 类 型 有 : 2 C 语 言 中 普 通 整 型 变 量 的 类 型 说 明 符 为, 在 内 存 中 占 字 节, 有 符 号 普 通 整 型 的 数 据 范 围 是 3 整 数 -35 在 机 内 的 补 码 表 示 为 4 执 行 下 列 语 句 int

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

上海市本科教学质量年度报告

上海市本科教学质量年度报告 上 海 市 本 科 教 学 质 量 年 度 报 告 数 据 内 涵 说 明 V2.0 版 上 海 市 教 委 高 教 处 上 海 喆 思 (2015.07.02) 目 录 一 基 本 统 计 挃 标 说 明... 4 二 挃 标 解 释... 4 1. 全 日 制 在 校 本 科 生 数 及 占 在 校 生 总 数 的 比 例 ( 学 年 )... 4 2. 当 年 本 科 招 生 与 业 总 数

More information

四川省普通高等学校

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

More information

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 第 六 讲 指 针 与 字 符 串 1 内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2 指 针 什 么 是 指 针 指 针 的 定 义 与 运 算 指 针 与 一 维 数 组 指 针 数 组 行 指 针 与 二 维 数 组 指 针 与 引 用 指 针 与 函 数 3 指 针 定 义 什 么 是 指 针 指 针 变 量, 简 称 指 针, 用 来 存 放

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

tbjx0048ZW.PDF

tbjx0048ZW.PDF 96 3 10 71 3 1 7 π π π ( ) 3 a 1 6 x + 1 1 x + 1 7 x + 5 + 1 x + 4 = x m = b - d a -c cb - ad n = a - c m = 4 - (-3) 8-7 = 7 1 = 7 n = 7 3 8( 4) = 53 8 7 a1 a a3 a N a n 0 + + 3 + L+ n 10 10 10 10 7 355

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

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

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

80 , 1993 45 000, 17, 70,160,,, :,, ;,,,,,,,,,, 2004 80,,,,2004 80 2004 80 2004, :,,,,, 2004,,,,, 2004 80, 1 ,,,,, : yqingg@hotmail.com 2004 80 2004 5 2 1 1 1 2004 2 8 2004 ( 2004 ) 12 13 13 13 14 14

More information

Microsoft Word - 2008年9月二级C真卷.doc

Microsoft Word - 2008年9月二级C真卷.doc 机 密 启 用 前 2008 年 9 月 全 国 计 算 机 等 级 考 试 二 级 笔 试 试 卷 C 语 言 程 序 设 计 24 注 意 事 项 一 考 生 应 严 格 遵 守 考 场 规 则, 得 到 监 考 人 员 指 令 后 方 可 作 答 二 考 生 拿 到 试 卷 后 应 首 先 将 自 己 的 姓 名 准 考 证 号 等 内 容 涂 写 在 答 题 卡 的 相 应 位 置 上 三

More information

Microsoft PowerPoint - ds-1.ppt [兼容模式]

Microsoft PowerPoint - ds-1.ppt [兼容模式] http://jwc..edu.cn/jxgl/ HomePage/Default.asp 2 说 明 总 学 时 : 72( 学 时 )= 56( 课 时 )+ 16( 实 验 ) 行 课 时 间 : 第 1 ~14 周 周 学 时 : 平 均 每 周 4 学 时 上 机 安 排 待 定 考 试 时 间 : 课 程 束 第 8 11 12 章 的 内 容 为 自 学 内 容 ; 目 录 中 标 有

More information

第5章修改稿

第5章修改稿 (Programming Language), ok,, if then else,(), ()() 5.0 5.0.0, (Variable Declaration) var x : T x, T, x,,,, var x : T P = x, x' : T P P, () var x:t P,,, yz, var x : int x:=2. y := x+z = x, x' : int x' =2

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 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

碩命題橫式

碩命題橫式 一 解釋名詞 :(50%) 1. Two s complement of an integer in binary 2. Arithmetic right shift of a signed integer 3. Pipelining in instruction execution 4. Highest and lowest layers in the TCP/IP protocol suite

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 pnzwzw@163.com 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

Chapter12 Derived Classes

Chapter12   Derived Classes 继 承 -- 派 生 类 复 习 1. 有 下 面 类 的 说 明, 有 错 误 的 语 句 是 : class X { A) const int a; B) X(); C) X(int val) {a=2 D) ~X(); 答 案 :C 不 正 确, 应 改 成 X(int val) : a(2) { 2. 下 列 静 态 数 据 成 员 的 特 性 中, 错 误 的 是 A) 说 明 静 态 数

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

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

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

e 2 3 2

e 2 3 2 e 1 3 3.1 3.2 3.3 NextDate 3.4 3.5 3.6 3.7 3.8 3.9 3 1 e 2 3 2 e 3 3.1 3.1.1 3.1.2 3.1.3 3.1.4 Return 3 3 e 4 3.1.1 1 2 1 2 3 4 3 4 e 5 3.1.2 3 5 e 6 3.1.3 FAX MODEM 3 6 e 7 3.1.4 ANSI/IEEE829-1983 3 1

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

zt

zt !!!!!!!!!!!!!!!!!!!! $ $ $ $ $ $ $ $ $ $ % $ % (!$ $ &% ) $ $ *) $ $ $ $ $ $ +) $ $ $ $ $ $,) $ $ $ $ $ $ -) $ $ $ $ $ $!) $ $ *) $ $ $ +) $ $ $,) $ $ $ -) $ $ $ () $ $ *) $ $ $ +),) -) &) $ $ *) +),)!

More information

2012年全国计算机等级考试二级C语言考试大纲

2012年全国计算机等级考试二级C语言考试大纲 2016 年 全 国 计 算 机 等 级 考 试 二 级 C 语 言 考 试 大 纲 基 本 要 求 1. 熟 悉 Visual C++ 6.0 集 成 开 发 环 境 2. 掌 握 结 构 化 程 序 设 计 的 方 法, 具 有 良 好 的 程 序 设 计 风 格 3. 掌 握 程 序 设 计 中 简 单 的 数 据 结 构 和 算 法 并 能 阅 读 简 单 的 程 序 4. 在 Visual

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

untitled

untitled 1 1.1 1.2 1.3 1.4 1.5 ++ 1.6 ++ 2 BNF 3 4 5 6 7 8 1.2 9 1.2 IF ELSE 10 1.2 11 1.2 12 1.3 Ada, Modula-2 Simula Smalltalk-80 C++, Objected Pascal(Delphi), Java, C#, VB.NET C++: C OOPL Java: C++ OOPL C# C++

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 trio@seu.edu.cn 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