nooog

Size: px
Start display at page:

Download "nooog"

Transcription

1 C : : :

2 , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, , 7 8, 12 13,,,,,

3 1 (1 ) 1.1 (1 ) ( ) ( ) ( ) ( ) ( ) 1.2 ( ) ( ) ( ) ( ) ( ) ( ) 1 ( ) 2 C ( ) 2.1 C ( ) C ( ) C ( ) 2.2 C ( ) 2.3 C ( ) 2.4 C ( ) C ( ) C VC ( )

4 2 ( ) 3 ( ) 3.1 C ( ) ( ) ( ) 3.2 ( ) ( ) ( ) 3.3 ( ) ( ) ( ) 3.4 ( ) ( ) ( ) 3.5 ( ) ( ) ( ) 3.6 ( ) ( ) ( ) ( ) ( ) ( ) 3.7 ( ) ( ) ( ) 3 ( ) 4 ( ) 4.1 ( ) C ( ) C ( ) 4.2 ( )

5 4.2.1 ( ) ( ) 4.3 ( ) getchar ( ) putchar ( ) gets ( ) puts ( ) 4 ( ) 5 ( ) 5.1 ( ) 5.2 ( ) 5.3 ( ) if ( ) switch ( ) 5.4 ( ) while ( ) do - while ( ) for ( ) ( ) ( ) 5.5 ( ) break ( ) continue ( ) 5.6 ( ) 5 ( ) 6 ( ) 6.1 ( ) ( ) ( ) 6.2 ( ) 6.3 ( ) 6.4 ( )

6 6 ( ) 7 ( ) 7.1 ( ) ( ) ( ) 7.2 ( ) ( ) ( ) ( ) 7.3 ( ) ( ) ( ) 7.4 ( ) ( ) ( ) 7.5 ( ) ( ) ( ) ( ) ( ) 7.6 ( ) 7 ( ) 8 ( ) 8.1 ( ) ( ) ( ) ( ) 8.2 ( ) ( ) ( ) 8.3 ( ) ( )

7 8.3.2 ( ) ( ) ( ) ( ) 8.4 ( ) ( ) ( ) ( ) 8.5 main ( ) 8.6 ( ) 8 ( ) 9 C ( ) 9.1 ( ) ( ) ( ) ( ) 9.2 ( ) ( ) ( ) 9.3 ( ) 9.4 ( ) 9 ( ) 10 ( ) 10.1 ( ) ( ) ( ) ( ) ( ) 10.2 ( ) ( ) ( ) 10.3 ( )

8 10.4 ( ) 10.5 ( ) 10.6 ( ) 10 ( ) 11 ( ) 11.1 ( ) 11.2 ( ) ( ) ( ) 11.3 ( ) ( ) ( ) 11.4 ( ) 11 ( ) 12 ( ) 12.1 C ( ) 12.2 ( ) fopen ( ) fclose ( ) 12.3 ( ) ( ) ( ) ( ) ( ) 12.4 ( ) 12.5 ( ) 12.6 ( ) 12 ( ) 13 C + + ( ) 13.1 ( )

9 13.2 C + + ( ) C + + ( ) C + + ( ) C + + ( ) C + + ( ) 13 ( ) 1 ( ) 2 ASCII ( ) 3 C VC ( ) 4 ( ) 5 C ( ) ( )

10 1 N - S :, : N - S, ??,,,,,, ( ),,,,,,,,,,,,, : 10,,,

11 , ,, ( Algorithm) 9 al - k hovarizmi,,,,,,,,,,, 1.1.2,,,,,,,, :,,,,,,,, : 07 68,,, 1,, 1h A B,, 10h,,,,,,,,,,,,,,,,,,, : x = 1, y = 0, z = x/ y;,, z = x/ y,,, 99 98, 99 98,,,, : (1 ),,,,, :,,,

12 ,,,,,, (2 ),,,,,,,, :,,,, (3 ),,,,,,, 1.1.3,,,, (1 ),,,,,, : , :,,,,, : 1 : 3 x, 13 y ; 2 : x + y, z ; 3 : z , 7,,,, : 1 :100 y, 7 x; 2 : y x, 3 ; 3 4 ; 3 :, 5 ; 4 : ; 5 :,,,,, ;,,,,

13 ,,,,,,,, 100 7,,,,,, ( :?) : 1 :7 x, 100 y; 2 : y% x = 0? 0 3 ; 3 4 ; 3 :, 5 ; 4 : ; 5 : (2 ) ( ) ( ) ( ),,,,,,,,,,,, N - S (3 ) N - S,,, (, ) ( ),,,,,, ( ), 1.2, ( A B ),, A, B,,

14 ,,, ( 1.3 ) ( 1.4 ) ( ) 1.3,,, C A B, A, B, A, B,,,,, 1.4, A, , C1,, A1 An + 1, C1,, C1 C2 Cn, An + 1, An ,, 1.6, C1 C2 Cn, ( ) 1 6 ( ),,,,, ,, C,, A( A, A ), A,, A, A C, C,, ( B ) 1.8,, A( A ), A( ),, A, A C,

15 C,, ( B ) ,, C A, C,, ( B ) 1 7 ( ) 1 8 ( ) 1 9 ( ) :, : 1.7,,,, C, ,, C,,,, A B, 1.4 A, 1.5 A1 A2 An An + 1, 1.6 A1 A2 An, A B,,,,,,,,,,,,, : ; ; ; ( ), I.Nassi B.Shneiderman,, N - S, N - S N - S N - S,,, ( ),, N - S, , , N - S,

16 ( ) 1 12 ( ) 1 13 ( ) 1 14 ( ) 1 15 ( ) 1.3 N - S x : x,,,,, -x, x, x, N - S 1.16, N - S 1 17, : 1 : x ; 2 : x 0, x, 4 ; 3 : -x; 4 : (4 ),, ( ),,,,, 1.3 : x if x > = 0 x x : x

17 x : x if x is positive then print x else print x x x ,?,,,,,,,,,,!,,,,,,!,,,,!, :,! 2?, :,,, :,,,,,,,,, x, y,,,,,,, 3,,, : , x y, ( 6 ),,, = +,,,

18 ,, 1.1.5,,,,, :,,,,,,,, 10min,, 0.1s,,,,,,,,,,,,,,,, ;, ( ), ,,, ( ) ( ),,,,,,,,,,,,,,, 1.2.2,, : C C + + Java BASIC Fortran Pascal Cobol ;,, : 1,,,,, 0 1,

19 ,,,,, 2,,,,, ( ),,, ( ), 3,,,, C BASIC Pascal Fortran, ( ),, 4,,,,, : Excel PowerBuilder FoxP ro - 4GL, C + + 5,,, C, C ( C ), C, C, 1.2.3, :,,,,,,,,,,,,,,,,,, 1.2.4,,,,,,,, ( ),,,,,,,,,,,

20 ,,,, 1.2.5, 3 ( ),,,,,,, ( 9 ),,,, 3, C, C, C,, C, C, C,,,,,,,,,, 1 1 a, b, c,, 2 a, b, c,,

21 2 C C C C C : C, C, C : C 2.1 C C C ( A T & T ) C B.W.Kernighan D.M.Ritchit T HE C PROGRAMMING LA NG UA GE K & R, K & R, K & R C, C, 1983, ANSI C C C,, C,,, ( bit) C, C,,, C,, C C U NIX C

22 , 20 80, C,, 2.2 C, C, ( A Z, a z) (0 9 ) _, : zz, x1, _5y, temp1, mum8 : 6s x T ( : ) ( : ) - 6x ( : ) zhue - 1 ( : - ) C : 1. : C, C (1 ) :, int double (2 ) :, if else for C,, 32, au to double int struct break else long switc h case e nu m r egister typedef cha r ex tern ret urn union con tinu e float shor t unsigned const for signed void default got o sizeof volatile do if static while 2., define C,,, 3.,

23 , ;,,,, : C, C, C,, C, BOO K book,,, 2.3 C C,, C C 2.1 {printf( I am a Student! \ n ) ; : main, C ( main ) printf C, I am a Student! \ n I am a Student!, C 2.2 # include stdio.h # include math.h / / { double x, y; / / x, y printf( input number: \ n ) ; scanf( % lf, & x ) ; / / x y = cos ( x) ; / / x, y printf( cos of % lf is % lf\ n, x, y) ; / / : x, x main, include

24 11 ), < > ( / / / /,, 4 x y 6 x, 7 x, y 8 % lf x y 2.3 # include stdio.h int min (int x, int y) ; { int m, n, r; / / scanf( % d, % d, & m, & n ) ; / / m n r = min ( m, n ) ; printf( min = %d, r) ; / / r int min (int x, int y) / / min, r / / min,,x y { int z; / / min z : if( x > y) z = y; else z = x; return(z) ; / / x y z : main min / / min, z min : x y z return z main main scanf, m n & m & n & %d, % d : main 3 min, m n min x y, min, r 3, C : C C C main,,,, printf scanf,, 2.3 min C C,, C main, C main (include ),

25 ,, C, C / / / /, / /,, /, /, / /, / / 2.4 C C C C C C,, C C.c.cpp C,.obj ( ),,, scanf printf,,,,.exe,.exe C C C VC Vis ual C Windows, Visual Basic Visual Foxpro Visual J + + Visual Studio ( Developer Studio) Developer Studio,, Developer Studio, VC C 1.VC (1 ) VC :

26 Microsoft Visual Studio 6.0 Microsoft Vis ual C Visual C VC , 2.2, 2.2 VC + + (2 ),, (3 ) VC + + File Exit 2.2, VC C (1 ) C File N ew ( : ^N ) 2.3 Files, 2.3 File C (.c,.cpp, ), Loca tion 2.3 C + + Source File, OK, VC + +, C,, File Save ( ^S ) C 2.3 C (2 ) C C,

27 File Open ( :^O) 2.4, C, VC + +,, 3. C 2.4 C 2.2 Build Compile, 2.5, 2.5,, 2.6 ( xxx C ) : xxx.obj - 0 error ( s ), 0 warning ( s) ( warning), (error ), 2.6,, VC + +, C,, 2.6

28 2.2 Build Build ( F7 ),,, ( xxx C ) : xxx.exe - 0 error ( s ), 0 w arning ( s) (error),, VC + +, C, ( ), Build! Execute ( ^F5 ).exe, VC , ( ) ( : C,!) ( ), VC + +,, 5. VC , C,,, C, ; 2.2 File Close Workspace 2.8,, , C, C,, C,, C C,,

29 1. A. C B. C C. C D. C, 2.C A. B. C. D. 3. A. C B. { C. C, D. C, 4. A. C B. C C. C D. C 5. A. C B. C main C. C, D. C 1., C 2.C,? 2

30 3,, :,,, : 3.1 C C,, 3.1 (int) (float) ( double) (char) (void) (array) ( struct) ( union) (enum) 3 1

31 , 2,, C : 3,, 4,,, 2.3 min, : int min(int x, int y ) int 2.2, cos,, y,,, void ( 7 ), , C (int ) ( float) (char ),,, : ;, : ;, : g 1 C,,, : # define # define ( #, 11 ),,,, PI 3.1 s # include < stdio.h > # define PI

32 { float s, r; r = 5; s = P I r r; printf( s = % f\ n, s ) ;,,, C, C : ( ) : ;,,, C 1,, 0 9, ( : 0 ) 23D( : D ) 2 0, 0, 0 7 : 015( 13 ) 0101( 65) ( 65535) : 256( : 0 ) 03A2( : A )

33 3 0X 0x, 0 9, A F a f : 0X2A( 42) 0XA0 ( 160 ) 0XF FFF ( 65535) : 5A ( : 0X) 0X3 H ( : H), : int, 4, : short int short, 2, : long int long, 4, : unsigned : un signed int un signed; un signed s hort ; un signed long, VC + +, 3.1 ASCII [ signed] int (2 31-1) 4 [ signed] short [int] (2 15-1) 2 [ signed] long [int] (2 31-1) 4 unsigned [int] ( ) 4 unsigned short [ int] ( ) 2 unsigned long [ int] ( ) 4 C, L l : 325L ( 325), 045L ( 37), 0X18L ( 24 ), U u : 453u, 0x67Au, 872Lu 0XB5Lu B5, 181, 0, u 2 :,,...;

34 3.2 # include < stdio.h > { int a = 1, b = 2, c; / a b c, a b 1 2 / long x = 29, y = ; c = a ; a = 10; / a c / / a 10 / printf( \ na + b = % d, x + y = % ld, c = % d\ n, a + b, x + y, c) ; : a + b = 12, x + y = , c = 1, :,, ;,, c = a; long x = 29, y = ;, 3.4 C,, : , 0 9 ( ) : 0.0, 123.,. 123, 12.3, 123.0, , e E (, ) e1, E0, e - 2 : a E n ( a, n, a 10 n ) : : E3( : E ) E6( : ) 4.2E( : ) ( float ) ( double) ( long double),, A NSI C

35 , float 4, double 8 7 8, 15 16, 3.3 # include < stdio.h > { float x = ; double y = ; printf( x = % f, y = % lf\ n, x, y) ; : x = , y = : x float, 8, , x,? : (1 ), (2 ), (3 ), 6 6, , , 56, 6,,, ASCII, 6 ASCII 54, C, \,,,,,, printf \ n,, 3.2 C, \,,, \ \ \ \,, H appy birthday!, printf( \ H appy birthday! \ ) ;

36 3.2 \ n ( ) \ t \ b ( ) \ f ( ) \ r \ \ ( \ ) \ \ ( ) ( ) \ xhh 1 2 \ ddd # include < stdio.h > { int x = 16, y = 2008; printf( y = % d\ rx = % d\ n, y, x ) ; printf( % c% c% c \ b%.1f\ n, C, +, +, 6.0) ; : x = 1608 C y = 2008 \ r,, x = x 16, x = 16,, y = 20, \ n,, C + +, \ b,, 6.0,, C , char ASCII x ASCII 120 a x, a 120 : ,, C,,,,,,, 3.5

37 # include < stdio.h > { char a = 66 ; int b = A ; printf( a = % d( % c), b = % d( % c), a + 3 = % c, b 10 = % d\ n, a, a, b, b, a + 3, b 10 ) ; : a = 66 ( B), b = 65 ( A), a + 3 = E, b 10 = 650, a 66, ; A b, ; a 3, b # include < stdio.h > { char a = x, b = Y ; / a, b / a = a - 32; / / b = b + 32 ; printf( % c, % c\ n, a, b) ; : X, y, a, b,, ASCII ASCII 32,, 3.6,, ;, : x + y - z/ 2 C C : C ( + ) ( - ) ( ) (/ ) ( %, ) ( + + ) ( - - ) 7, (1 ) + a + b, ( )

38 (2 ) -, -,, ( ), - x, - 5 (3 ), (4 ) /,,,,,,,,, 3.2 C, 0, (5 ) ( ) % 3 2,,, VC + +, : 16 % - 3 1, - 32 % # include < stdio.h > { printf( %d, % f\ n, 15/ 6, 15.0/ 6 ) ; printf( %d, % d, % d, % d\ n,100 %3, - 100%3,100 % - 3, - 100% - 3 ) ; : 2, , - 1, 1, - 1,15 6, 15/ 6 ( ) 15.0/ 6, 15.0, (6 ) ( + + ) ( - - ) C,, ( + + ) ( - - ) : + + : 1 : + + x ; x = x + 1; - - : 1 : - - x; x = x - 1; , ( ), ( ) : x = x + 1; + + x; x + + ; + + x( - - x ), : x 1 ( 1 ), x x + + ( x - - ), : x, x 1 ( 1) + + ( - - ), 1 ( 1 ), 1( 1 ), C,

39 3.8 # include < stdio.h > { int x1 = 10, x2 = 10, y1, y2; printf( \ nx1 = %d, x2 = % d\ n, x1, x2) ; y1 = + + x1; y2 = x2 + + ; printf( y1 = %d, x1 = % d \ n, y1, x1 ) ; printf( y2 = %d, x2 = % d \ n, y2, x2 ) ; : x1 = 10, x2 = 10 y1 = 11, x1 = 11 y2 = 10, x2 = 11, y1 = + + x1;, x1 11, ( 11 ) y1; y2 = x2 + + ;, x2 ( : x2 10 y2), x C, 15 1, 15,, C, ( ) ( ), x - y + z, y -, x - y, + z, x = y = z, =, y = z x = ( y = z) (1 ) : ( ) ; +, - ( ) ;,/ ; +, - ( ) + ( ) - ( ), (2 ), :,, ;,,, 3 : ( ) ( )

40 ( float)a a (int) ( x + y ) : x + y : (, ), : int( x + y),, ( int ) ( x + y ) (int) x + y, x int y,, 3.9 # include < stdio.h > { float f = 9.68; printf( (int)f = % d, f = % f\ n, (int) f, f) ; : (int) f = 9, f = ,, f f ( : ), : (int) f, 9( ) f 9.68, float C : > ( ) > = ( ) < ( ) < = ( ) = = ( )! = ( ) ; : & & ( ) ( )! ( ) ( true) ( flase), true 0, flase 0 : 6 > 8 0, 12 > = 5 1, = = 9 1, 10!= ,!( 4 5 ) = = 0 1,2 & & 8 = = 1 1, 0 9 = = 0 0 :! > > = < < = = =! = & &! ( ) :, : int a = 75; printf( " a = % d", a > 60 ) ; 1,, : 0,,, 0;,

41 1, x = 23, y = 20, z = 10;, x > y > z, C, x y, z 1, x > y > z 0( 1 ), x > y & & y > z # include < stdio.h > { int x = 6, y = 4, z = 2, v, w ; v = x - - y; w = ( y - 4 ) & & ( + + x + 1 ) ; printf( v = % d, y = % d, x = % d, w = % d\ n, v, y, x, w) ; : v = 1, y = 4, x = 6, w = 0, x = 6, v 1 (, - - y ), y 4 y - 4 0, w 0 (, + + x + 1 ), x =, : = :,, : :, : x = 12, y = x + 25, y = func( ) =, : C x = x + 1, x 1, x, x = x + 1,, :, C =, :,, : x = y = z = :, x = y = z = ( ), ( ) : x = ( y = (z = ( ) ) ), x = ( y = (z = ) ), :

42 16 z = : , 16 z, z 16, ( z = ) y = (z = ) : (z = ) 16 y, y 16, ( y = (z = ) ) 16 ;, x, y, z 16,,, 2, = ;,,, : = ;, x = x + y; x + = y;, x = x ( y + z) ; x = y + z;, + = = C, C 10 : + = ( ), - = ( ), = ( ),/ = ( ), % = ( ), & = ( ), = ( ),^ = ( ), < < = ( ), > > = ( ) 3.11 # include < stdio.h > { int a = 0, b = 3, c = 1 ; a + = (a = 2) ; printf( %d, % d\ n, a, b + = b - = b b) ; printf( %d, % d\ n, c = - - b + 2, c = 9) ; : 4, ,9, printf printf,,, VC ,, c = 9 (, c 1, c 9 ), 9, c = - - b + 2, c = c ( - - b + 2 ) = 9 ( ) = - 99, printf, : 4, , ?: C?,, :

43 1?: 2: 3 : 1,, 2, 1, 3,, x = ( a > b)? a : b a b y = ( x > = 0)? x: - x x 2,,,, : 1, 2, 3,, n, : 1, 2, n, n : a = 8 2, a 4 ; / 64, a 16 / (a = 8 2, a 4), a 2; / 128, a 16 / a = ( b = 5,5 2) ; a = b = 5, 5 2 ; /, 10, b 5 / /, 10, a b 5 /,,, 3.6.5,, 1,, : char ch = d ; int i = 6; float f = 10.0; double d = 0.2, result ; Result = (ch/ i) + (4 + f d ) ( f - i) ; , :,,, int a ; long int b = E2 ; a = ( int) b;, a 145 ( ), int a; long int b = ( int ) E10; a = ( int ) b ;, a

44 ,,,,,, b, : C 4 : & ( ) ( ) ^( ) ( ) C : < < > > (1 ) ( : ) : < < > > & ^ (2 ) x y x &y x y x^y x & : 1, 1, 0 0,, a = , a & , : 0, 0; a & a , :, ; a & 0x0f , : a 4 0, 4 : 0, 0, 1 1 : a = , a , : 0, ; a a , :, ; a 0x0f , : a 4, 4 1 ^

45 3.7.2 :, 0, 1, : a = , a^ , : 0, ; a^a , :, 0; a^0x0f , : a 4, 4 :, :0 1,1 0 : a = , a < < > > : : 1 > > 2 1 < < 2 ( : ) ( : ) 1, 2,, 0, 1,, 1, 0; 1, 1 0, 0,, 1, 3.12 x 4 7 { un signed int x, y, z ; scanf( % x, & x) ; / / x y = x > > 3 ; z = y & 0x0f; printf( x = % x, z = % x \ n, x, z) ; / / 3, 4 7, y : (, 5a) x = 5a, z = b / / y 0x0f( 4 0, 4 1 ) C,,,,,,,

46 1. 4, A. _main enclude sin B. If - max turbo C. txt REAL 3COM D. int k_2 _001 2., A. _1234_ B. _1_2 C. int_2_ D. 2_int_ 3. C A B B C. 0Xffa D. 0x2H 3 4. A. 5E2.0 B. E - 3 C..2E0 D. 1.3E 5.C A. % = B./ C. = D. < = 6. : int m = 7, n = 12;, 3 A. n% = ( m% = 5) B. n% = ( m - m%5 ) C. n% = m - m%5 D. ( n% = m) - ( m% = 5 ) 7. A. 0 < = x < 90 B. i = j = = 0 C. ( char) ( ) D. x + 1 = x int m = 2, n = 1, q;, q = n/ m ;, q A. 2.5 B. 3 C. 3.0 D. 2 9., A. x1 = 26.8% 3; B. x2 = j > 0; C. x3 = 01A ; D. x4 = = 3; 10., A. a = 1/ b = 2 B. + + (a + b) C. a = a/ ( b = 5) D. y = int( a) + b 1. : float t = 2, x = 3.5;, : ( (int) x )/ t 2. : char x = A ;, x + = x% = x x, y, z, k int, x = ( y = 4, z = 16, k = 32 ), x 4. int m = 3, n = 4, x;, x = - m + + ; x = x + 8/ + + n;, x 5. # include < stdio.h > { int y = 3, x = 3, z = 1;

47 printf( %d, % d\ n, ( + + x, + + y ), z + 2) ; 6. # include < stdio.h > { int a, b; float c, d; a = - 23; b = 4; printf( a/ b = % d\ n, a/ b) ; printf( a% b = % d\ n, a % b) ; c = d = 5; c = c + (c = 1 ) ; d + = 10; printf( d/ = c: % f\ n, d/ = c) ; printf( a = % d, b = %d, c = % f, d = % f\ n, a, b, c, d ) ; 7. # include < stdio.h > { int x = 3, y = 5, z = 8; y = x + 3 x + y; z % = x + y + 3; x = y > z; printf( %d, % d, % d\ n, x, y, z) ; z = ( x + = x = + + y - z - - ) ; printf( %d, % d, % d\ n, x, y, z) ; 8. # include < stdio.h > { int x, y, z; x = y = z = 1; y + + ; + + z; printf( y = % d, z = %d \ n, y, z) ; x = ( - y + + ) + ( + + z) ; printf( x = %d, y = % d, z = % d\ n, x, y, z) ; x = y = 1 ; z = + + x y + + ; printf( x = %d, y = % d, z = % d\ n, x, y, z) ;

48 1., a b c d 2. a, b, c, : area = s ( s - a) ( s - b ) ( s - c), s = ( a + b + c)/ 2, a, b, c, area : sqrt( x ), math.h

49 4 C / : : scanf printf C 1, 3,,, C C C, C, C 5 : 1 ;, : ; : x = y + z ; / /, y z, x y + z; / /,, i + + ; / / i 1

50 2 ;, : ( ) ;,, ( 7 ) : printf ( C P rogram ) ;, C Program 3, C 9, : : if switch ; : do while while for ; : break goto continue return 4 {,, : { x = y + z ; a = b + c; printf( % d% d, x, a) ; : { ;, 5 ;, : while( getchar ( )! = \ n ) ;,,, :,,, / C C, / C C / / /, / : scanf/ printf getchar/ putchar gets/ puts, C, # include < > VC , stdio.h, : # include < stdio.h > # include stdio.h,,, ( Warning)

51 4.2 C,,,,, printf,,, ( ) 1 printf printf : printf(, ) ;,,,, (, ),,,,, : printf( % d % d, a, b) ;, % d % d, a b, : 2 : % [ ],,,,, (1 ),, 4.1 : %, 4 1 % : int d = 15; printf( d = % d, d ) ;, 1 d, ; 3 d, ; % 2 d, d : d = 15

52 4.1 % d, % u % x, % X % u % o % f ( ), 6 %e, % E % g, % G % f % e %c % s, \ # include < stdio.h > { int a = 15; float b = ; char d = p ; printf( a = % d, %o, % x\ n, a, a, a) ; printf( b = % f, % e \ n, b, b ) ; printf( d = % c \ n, d) ; printf( % s\ n, programming ) ; : a = 15,17, f b = , e d = p progra mmi ng, a 15, b, 6 ;, (2 ),,, :

53 int a = 123, b = ; printf( a = %d,, a) ; printf( b = % d\ n, b) ; printf( H appy birthday! \ n ) ; : a = 123, b = H appy birthday! 1 printf, a =,, 2 printf b =, \ n ( 3 ),, printf,, (3 ) : l, h, d f u # include < stdio.h > { long int a = ; int b = 12345, c = 45678; double d = ; printf( a = % ld, b = % hd \ n, a, b ) ; printf( c1 = % d, c2 = % hd \ n, c, c) ; printf( c3 = % ld, d = % lf \ n, c, d) ; : a = , b = c1 = 45678, c2 = c3 = 45678, d = % ld % hd %lf, b c ( VC , 4, , 2, ),, b, ; c,,,,,, l L (4 ),, %,,,, %,, : %d, ; % f % e % E,

54 ; % s,, : % md m, m % m.nf m, n % ms m, m % m.ns m n, m 4.3 # include < stdio.h > { int a = 1, b = 100, c = 1000; float d = ; char ch [ ] = Cprogram ; printf( %3d\ n% 3d\ n%3d \ n, a, b, c) ; printf( %0.3d\ n% 0.3d\ n%0.3d \ n, a, b, c) ; printf( %7.2f\ n%5.2f\ n%2.7f\ n, d, d, d) ; printf( %5s \ n%7.3 s\ n% 2.6s \ n, ch, ch, ch) ; : Cprogr am Cpr Cprogr,,, ( m > 0) 0( m = 0 m ), ( ) ;, ;,,, ;,

55 :,, (5 ) printf, :,, +, +,, - # 0, 0x ( ), ( - ) 4.4 # include < stdio.h > { int a = 64, b = 12345; float c = ; printf( %3d\ n, a) ; printf( % - 3d\ n, a) ; printf( %7.2f\ n, c) ; printf( % - 7.2f\ n, c) ; printf( %10 s\ n, Cprogram ) ; printf( % - 10 s\ n, Cprogram ) ; printf( % + 5d\ n, b) ; printf( % 5d\ n, b) ; printf( % # o\ n, a) ; printf( %o\ n, a) ; : Cprogr am Cprogr am

56 4.2.2 scanf, stdio.h, 1 scanf scanf : scanf(, ) ;,, printf,,, &,,, scanf( % d% d, & a, & b), ( ) C, ( ) :, 4.5 # include < stdio.h > { int a ; float b, c ; printf( input a, b, c\ n ) ; scanf( % d% f % f, & a, & b, &c) ; printf( a = % d, b = % f, c = % f\ n, a, b, c) ;, scanf %d% f % f,, scanf ( % d% f % f, & a, & b, & c) ;,,,, < Tab >, : Tab : a = 7, b = 4.6, c = 7.9 : scanf % d, % f, % f,,,,,,,, : 7, 4.6, 7.9, scanf, int

57 a ;, scanf( % d, a) ;, scanf( % d, & a) ; 2 scanf, : % [ ],, (1 ), scanf scanf d o x u f e c s ( ), a, b c, scanf % d f,, scanf, scanf( % d% f % f, &a, & b, &c) ; scanf( % f % f% f, &a, & b, & c) ; (2 ) scanf : ( ) l h, scanf l h :, : int a, b, c; scanf( %2d% 3d%4d, & a, & b, &c) ; : , a b c , :, 4.6 # include < stdio.h >

58 { int a, b, c; scanf( % d% d% d, &a, & b, &c) ; printf( a = % d, b = %d, c = % d\ n, a, b, c) ;, : 1 2 3, : a = 1, b = 3, c = ( ),1 a, 2, 3 b c, l h : ( l) ( h ) l h d o x, % ld % lo % lx % hd % ho % hx, l f e ( % lf % le), double : long a; short b; scanf( %10ld% hd, &a, & b) ; a 10, b : , a , b 11 (3 ), scanf,,, int a, b; scanf( % d, % d, &a, & b) ;,, : 1 < > 2, a 1, b 2,,,, : 1, 2 : scanf( a = %d, b = % f, c = % c, &a, & b, &c) ;, : 1, 2.1, a,,, ( a =, b =, c = ) scanf,, : a = 1, b = 2.1, c = a,,,,,,,, : int a ; char ch ; scanf( % d% c, &a, & ch) ; :23 < > a, a 23, ch a, 3 ch, : scanf ( % d% c, &a, & ch ) ; scanf ( % d % c, &a, &ch ) ; % d, a,

59 4.7 # include < stdio.h > { char a, b; printf( input character a, b\ n ) ; scanf( % c% c, & a, & b) ; printf( % c% c \ n, a, b) ; :, M N, : M, scanf % c% c, : M N, M, : MN, MN,,, 4.8 # include < stdio.h > { float a, b, c; scanf( % f, % f, % f\ n, & a, & b, &c) ; printf( a = % f, b = % f, c = % f\ n, a, b, c) ;, 3.5,4.6,7.9,,,, \ n, (, : 3.5, 4.6, 7.9 \ n, ), \ n,,,,, 4.3 C : getchar putchar, getchar getchar : getchar ( ) : ( ), getchar,, char c; c = getchar( ) ; 4.9 # include < stdio.h >

60 { char c; printf( input a character \ n ) ; c = getchar( ) ; putchar( c) ; getchar : getchar, getchar ( ),,,, getchar, ; : abcde, getchar a, 96, c 9, getchar 9, 9 : putchar ( getchar( ) ) ; printf( % c, getchar( ) ) ; putchar putchar : putchar(ch), ch ( ) : ( ), : putchar ( A ) ; ( : A) putchar ( x) ; ( : x, : x ) putchar ( \ 101 ) ; ( : A, \101 A ) putchar, :, : p utchar ( abc ) p utchar ( abc ),, putchar ( A ) ; 4.10 # include stdio.h { char o = M, k = Y ; putchar( o) ; putchar( k) ; putchar( \ n ) ;

61 putchar( ) ; : MY,, getchar putchar( ch ),, scanf printf, % s,, gets puts,, C,, \ 0, \ 0, C,, : char ch [100 ] = H ello World ; ( 6 ) gets gets : gets ( ) : ( ) gets,, scanf puts puts : puts( ) : 4.11 # include stdio.h { char c[ ] = Hello - World! \ n, st[ 15 ] ; printf( input string: ) ; gets ( st) ; printf( result is: % s \ n, st) ; puts (c) ; (, H ello World ) : input string: H ello World res ult is: H ello World H ello - World!

62 , puts printf, printf : / scanf/ printf, / getchar/ putchar, / gets/ puts /, C,, scanf printf 1. int n1 = 10, n2 = 20; printf(, n1, n2 ) ; : n1 n2,, n1 = 10 n2 = : { int i, j; scanf( i = % d, j = % d, &i, & j) ; printf( i = %d, j = % d\ n, i, j) ; : i 10, j 20, 1. 3 ( 10.0, 20.0, 5.0 ), 3 sum product average 2. : sizeof ( ), 3. ( 20, 10 ), a b, : int 4, long int, float

63 5 if switch, while do - while for, :,, :,,, 5.1 C , ( ), : (1 ),, (2 ),,, (3 ),,,,,, ;

64 ,,, ( ) ;,,,, 3,, C,,,,, C, C, ( if switch ) ( while do - while for ) 5.2,,, 5.1 3, C,,, {,,, x y, : 5.1 { temp = x; / / x temp x = y; / / y x y = temp; / / temp y temp temp, : { int temp; temp = x; x = y; y = temp;,,,, ( ),,,,,,,, ( ),,

65 , 5.1, C F : F = 1.8 C + 32 : # include < stdio.h > { float C, F; printf( : ) ; scanf( % f, & C ) ; F = 1.8 C + 32; printf( : %6.2f\ n, F ) ;, 37, : : 37 :98.60 / / 5.2 r = 1.5, h = 3,,,,, : : L = 2 r, S = r 2, V = r 2 h 3, # define, PI, PI :, C,,, C, : # include < stdio.h > # define PI / / PI { double r, h, l, s, v; printf( r = ) ; scanf( % f, & r ) ; / / printf( h = ) ; scanf( % f, & h ) ; / / l = 2 PI r ; s = PI r r ; v = PI r r h ; printf( l = %6.2f\ n, l ) ;

66 printf( s = %6.2f\ n, s ) ; printf( v = % 6.2f\ n, v ) ; : r = 1.5 h = 3 l = 9.42 s = 7.07 v = x 2 + x - 3 = 0 : ax 2 + bx + c = 0, b 2-4ac 0, : x1 = - b + b2-4ac 2a a = 2, b = 1, c = - 3, b 2 x2 = - b - b2-4ac 2a - 4ac = 25 > 0, : a b c, b 2-4ac p, sqrt,, math.h, math.h : # include < stdio.h > # include < math.h > { float a, b, c, x1, x2, m; printf( a, b, c : ) ; scanf( % f, % f, % f, &a, & b, & c) ; m = sqrt( b b - 4 a c) ; x1 = ( - b + m ) / ( 2 a ) ; x2 = ( - b - m) / ( 2 a ) ; printf( x1 = % f\ n, x1 ) ; printf( x2 = % f\ n, x2 ) ; : a, b, c : 2,1, - 3 x1 = x2 =

67 5.3,,,, ax 2 + bx + c = 0, b 2-4ac 0, b 2-4ac < 0 b 2-4ac 0,,, ( ) C, if switch,, if 1 if C if : if if - else (1 ) if : if ( ) 1; :, ( 0), 1 ; (, 0 ),, (if ) : if, 5.2 1,,,,,, 5.2 if 5.4, : x, x, x < 0, - x x ;, x if : # include < stdio.h > { int x; printf( x : ) ; scanf( % d, & x) ; if ( x < 0) x = - x; printf( x = % d\ n, x) ;

68 : x : x = , x y z, 3, :, x y, x ;, x z, x,,3 x ;, y z, y,, t : # include < stdio.h > { int x, y, z, t ; printf( 3 : ) ; scanf( % d% d%d, & x, & y, &z) ; if ( x < y) {t = x; x = y; y = t; / x, y / if( x < z) {t = z; z = x; x = t; / x, z / if( y < z) {t = y; y = z ; z = t ; / z, y / printf( : % d % d % d\ n, x, y, z) ; : 3 : : (2 )if - else : if ( ) else 1; 2; :, ( 0), 1 ; (, 0 ), 2 : if - else,, 5.3, , :, 5.3 if - else

69 : # include < stdio.h > { char ch ; printf( Input a character: ) ; ch = getchar ( ) ; if( ch > = a & & ch < = z ch > = A & & ch < = Z ) printf( It is a lett er.\ n ) ; else printf( No, it is not a let ter.\ n ) ; : Input a character: A It is a let ter. Input a character: 8 No, it is not a letter. 2 if if, 1 2, C, if if, if (1 ) else - if else - if if, if - else 2 if, if else - if : if ( 1 ) 1; else if ( 2) 2 ; else else if ( n - 1) n - 1 ; else n; : 1, 1 ( 0 ), 1, if ;, 2, 2 ( 0), 2, if ;, ;,, n : else - if, 5.4, else - if if,,, else n,,

70 5 4 else - if 5.7,, 85, 60, : score, :, 85 score 100;,85 > score 60;, 0 score < 60, else - if : # include < stdio.h > { float scor e; printf( Input score : ) ; scanf( % f, & score) ; if ( score > = 85 & & score < = 100 ) printf( Excellent.\ n ) ; else if( score > = 60 & & score < 85) printf( Pass.\ n ) ; else if( score > = 0 & & score < 60 ) printf( No pass.\ n ) ; else printf( Error score.\ n ) ; : Input score : 90 Excellent. Input score : 75 Pass.?, score > = 60 score > = 0, (2 ) if if, if,, if : 1: if ( 1 )

71 if ( 2) 1; else 2 ; else 3; 2: if ( 1 ) { if ( 2 ) 1; else 2; 3: if ( 1 ) 1 ; else if ( 2 ) 2; else 3; 4: if ( 1 ) if ( 2 ) 1; else 2; else if ( 3 ) 3; else 4;,, if, if if - else, : if ( x > 0) if ( x > 100 ) y = 1; else y = 0; else if, : if if - else, else if if ( x > 0) if ( x > 100 ) y = 1; else y = 0; if - else 1 if, else if if ( x > 0) if ( x > 100 ) y = 1; else y = 0;, C : else if,, if,, : if ( x > 0) { if ( x > 100 ) y = 1 else y = 0;,,, else, if if 2,,,,, 5.8 ax 2 + bx + c = 0 : 5.3, ax 2 + bx + c = 0, b 2-4ac 0,, : a = 0 b 0,, x = - c/ b ; b 2-4ac = 0, : x = - b/ 2a ;

72 b 2-4ac 0, : x1 - b + b 2-4ac 2a, x2 - b - b 2-4ac ; 2a b 2-4ac < 0, : x1 = p + qi, x2 = p - qi, p = - b 2a q = - ( b 2-4ac) 2a, if, a b c, : if ( a = = 0 & & b = = 0 & & c = = 0 ) ; else if ( a = = 0 & & b!= 0 ) ; else { b 2 if ( m > = 0) else - 4ac m; ; { p ; : # include < stdio.h > # include < math.h > q; ; { float a, b, c, x1, x2, p, q, m; printf( Enter 3 coefficients a, b, c: ) ; scanf( % f, % f, % f, &a, & b, & c) ; if( a = = 0 & & b = = 0 & & c = = 0 ) printf( any value \ n ) ; else if ( a = = 0 & & b!= 0 ) else printf( x = % f\ n, - c/ b) ; { m = b b a c; if( m > = 0 ) { x1 = ( - b + sqrt( m) ) / ( 2.0 a ) ; else x2 = ( - b - sqrt( m) ) / ( 2.0 a ) ; printf( x1 = % f\ n, x1 ) ; printf( x2 = % f\ n, x2 ) ; / /

73 { p = - b / ( 2.0 a ) ; q = sqrt( - m) / ( 2.0 a ) ; printf( x1 = % f + % fi \ n, p, q) ; printf( x2 = % f - : % fi \ n, p, q) ; Enter 3 coefficients a, b, c: 2, 1, - 1 x1 = x2 = Enter 3 coefficients a, b, c: 2, 1, 1 x1 = i x2 = i switch else - if if,,, if, C switch switch : switch ( ) { case 1 : 1; break ; case 2 : 2; break ; case n: n ; break; default : n + 1; :,,, ;, default, break, switch - case, ( ) : switch,,,, 5.5

74 5 5 break switch switch, : switch case, case,, { default case, case case default, default, case, switch, C, switch : switch ( x) { case 1: switch (y ) { case 0: a + + ; break ; case 1: b + + ; break; break; case 2: a + + ; break ; case : switch ( x) { case 1: case 2: case 3: a + + ; b + + ; break; case 4: c + + ; break;, switch break,, break break,,, break break switch ( 5 6) : switch ( )

75 { case 1 : 1; case 2 : 2; case n: n ; default : n + 1; 5 6 break switch 5.6, 2, 2 n n + 1 switch : i = 1, switch (i) { case 0: printf( %d, i) ; break ; case 1: printf( %d, i) ; break ; case 2: printf( %d, i) ; break ; default : printf( % d, i) ; :1 switch (i) { case 0: printf( % d, i) ; case 1: printf( % d, i) ; case 2: printf( % d, i) ; default: printf( % d, i) ; :111, case 1 switch( y) break, case 0 a + + ; break;, switch ( y), case 2 a + + ; break;, switch( x), printf, : a = 2, b = 0 # include < stdio.h > { int x = 1, y = 0, a = 0, b = 0; switch ( x) { case 1: switch ( y) { case 0: a + + ; break; case 1: b + + ; break; case 2: a + + ; break; case 3: b + + ; break;

76 printf( a = %d, b = % d\ n, a, b) ; 5.9,, A B C D E 90 A, B, C, D, 60 E, :, 6, score, else - if, 5.7 : if ( score > = 90 & & score < = 100 ) printf( A \ n ) ; else if( score > = 80 & & score < 90 ) printf( B\ n ) ; else if( score > = 70 & & score < 80) printf( C \ n ) ; else if( score > = 60 & & score < 70) printf( D\ n ) ; else if( score > = 0 & & score < 60 ) printf( B\ n ) ; else printf( error! \ n ) ; switch switch case score , 101 case ( 101 case, ), (case ), caes, 100, 10, ;,,, 90, 9, 80, 8, score/ 10 switch, case 0 9, : # include < stdio.h > { int score; printf( Please enter score : ) ; scanf( % d, & score) ; switch ( score/ 10 ) { case 10: case 9: printf( % d A \ n, score) ; break; case 8: printf( % d B\ n, score) ; break; case 7: printf( % d C\ n, score) ; break; case 6: printf( % d D\ n, score) ; break; case 5: case 4: case 3: case 2: case 1: case 0: printf( % d E \ n, score) ; break;

77 default : printf( Input error! \ n ) ; : Please enter score : B Please enter score : A Please enter score : 110 Input error!,,, 101, A,, , score/ 10 10, case 10:, A if, 100, if - else switch : # include < stdio.h > { int score; printf( Please enter score : ) ; scanf( % d, & score) ; if( score < 0 score > 100) else printf( Input error! \ n ) ; { switch ( score/ 10) { case 10: case 9: printf( %d A \ n, score) ; break; case 8: printf( %d B\ n, score) ; break; case 7: printf( %d C\ n, score) ; break ; case 6: printf( %d D \ n, score) ; break; case 5: case 4: case 3: case 2: case 1: case 0: printf( %d E \ n, score) ; break;

78 5.4,,,,, C while do - while for,, break continue while while, :, while : : while ( ) ;, ( 0), ;,,,, ( 0), while, while, 5.7 : while :,, : (1 ), (2 ),, {,, 5 7 while (3 ), ;, ( ) 5.10 n, s = n, while :, : s, 0,, s, n, n : # include < stdio.h > { int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; / / n,n s = 0 ; i = 1 ; / /

79 while (i < = n) / /, { s = s + i ; / / i i + + ; / / printf( % d = % d\ n, n, s) ; : Please enter n: = ,, : # include < stdio.h > { char c; int num = 0; printf( : ) ; / / num 0 while( (c = getchar( ) )! = \ n ) / /,, num + + ; printf( = % d\ n, num) ; : : hi, ABC = do - while / / 1, do - while :, do - while : do{ ; while ( ) ; :,, ( 0 ),, 5.8 : do - while :, while,, do - while :,,,, 5 8 do - while

80 ;,,, { 5.12 n, s = n, do - while : # include < stdio.h > { int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; s = 0 ; i = 1 ; do / / { s = s + i ; / / i i + + ; / / while (i < = n ) ; / /, printf( % d = % d\ n, n, s) ; : Please enter n: = 1275,, while do - while,,,,,, : (1 ) while int i, s; s = 0 ; i = 5 ; while (i < 5 ) { s = s + i; i + + ; printf( s = % d, s) ; : s = 0 ( 2) do - while int i, s; s = 0; i = 5; do { s = s + i; i + + ; while ( i < 5) ; printf( s = % d, s) ; : s = 5 : while, i < 5, ; do - while,, i < 5, for for C, for while, while for : for ( 1; 2; 3 ) ;

81 : 1, 2, ( 0),, 3, 2,, 5.9 : for, 1,, ; 2,, ; 3, : for,, for ( ; i < 10 ; i + + ) sum + = i; for ( ; ; ) sum + = i ; ; / / i for 1 3, for (i = 0, j = 0 ; i < 100 ; i + +, j + + ) b[i] = a[j] ; / /, 5 9 for,, { ;, 5.13 n, s = n, for : # include < stdio.h > { int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; for (i = 1, s = 0; i < = n; i + + ) s = s + i ; printf( % d = % d\ n, n, s) ; : Please enter n: = n, n! :,, : s,, s 1,, s = s i(i = 1, 2, n ), n, n! : # include < stdio.h >

82 { int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; for (i = 1, s = 1; i < = n; i + + ) s = s i ; printf( % d! = 1 2 %d = % d\ n, n, n, s ) ; : Please enter n:5 5! = = 120,, C while do - while for,,,, : (1 ),, ( 2 ) for while, ; do - while for while, do - while (3 ) while do - while,, for (4 ) do - while (5 ) for,, C,,,, C,,,,,, ! + 2! + 3! n!, n :,, i i, i n, j i,

83 i, i : # include stdio.h { int i, j, n, t, sum = 0; printf( please Input n : ) ; scanf( % d, & n) ; for (i = 1; i < = n; i + + ) { t = 1 ; for (j = 1 ; j < = i; j + + ) t = t j; sum + = t ; / / n, / / i, / / i printf( sum = % d, sum) ; / / : please Input n : 8 sum = 46233, i i - 1 i, : # include stdio.h { int i, n, t, s um = 0; printf( please Input n : ) ; scanf( % d, & n) ; t = 1 ; for (i = 1; i < = n; i + + ) { t = t i ; sum + = t ; printf( sum = % d\ n, sum ) ; 5.16, 1 1 = = = = = = = = = = 81 :, 9 1,, i, 1 9, j i 9,

84 : # include < stdio.h > { int i, j, k ; for ( i = 1; i < = 9; i + + ) / /, 9 { for ( j = i; j < = 9; j + + ) / /, 9 - i + 1 { k = i j; printf( % d %d = % 2d, i, j, k ) ; printf( \ n ) ;, j = i; j < = 9; j = 1; j < = 9; j = 1; j < = i;,, 5.5,,, C break continue, C goto goto, goto, break break : break; break switch, switch, switch, break switch, switch, switch ,, : for,,, 10, i > 10 ;, break, : # include < stdio.h > { int s um = 0, x, i; printf( 10 : \ n ) ; for (i = 1; i < = 10; i + + ) / / i > 10, { scanf( % d, & x) ; / / x

85 if ( x < 0) break; / / x < 0, sum = sum + x ; printf( \ ns um = % d\ n, sum) ; : 10 : sum = continue continue : continue ; / / continue,, while do - while, ( ) ; for, 3 continue break : continue, ; break 5.18,, : while,, continue ( ),, : # include < stdio.h > { char c; printf( : ) ; while( (c = getchar( ) )! = \ n ) { if( c > = A & & c < = Z ) continue ; putchar (c) ; printf( \ n ) ; : : ABheKllow12 hellow12

86 , : :, 1 9, 9, i ( 1 i 9 ), 1 i, i 1,, i, ( for ) : # include < stdio.h > { int i, j; for (i = 1; i < = 9; i + + ) { for ( j = 1 ; j < i; j + + ) printf( % 3d, j) ; for ( j = i; j > 0; j - - ) printf( % 3d, j) ; printf( \ n ) ; : ,,,,, blank

87 # include < stdio.h > { int i, j, b lank = 30; for (i = 1; i < = 9; i + +, blank - = 3 ) { for ( j = 1 ; j < blank ; j + + ) printf( ) ; for ( j = 1 ; j < i; j + + ) printf( % 3d, j) ; for ( j = i; j > 0; j - - ) printf( % 3d, j) ; printf( \ n ) ; : ( ) : , 2008, 2008, 7 ( ),, : # include < stdio.h > { int year = 2008, month = 8, day = 8 ; int weekday = 2 ; int i, num, yeardays = 0 ; / / for (i = 1; i < month; i + + ) { / / switch (i) { case 1: case 3: case 5: case 7: case 8: case 10: / /

88 case 12: num = 31 ; break ; / / 31 case 4: case 6: case 9: case 11: num = 30 ; break ; case 2: if ( ( year %4 = = 0 & & year %100! = 0) / / 30 year %400 = = 0) num = 29; / / 29 else num = 28; break ; default : n um = 0; yeardays + = num; yea rdays = yeardays + day; / / weekday = ( yeardays weekday ) %7; / / 28 printf( % d % d % d % d\ n, year, month, day, weekday) ; : ,, : # include < stdio.h > { int year, month, day, weekday; int i, num, yeardays = 0 ; / /, : printf( : ) ; scanf( % d - % d - %d, & year, & month, & day) ; / / 1 1 printf( % d 1 1 :, year ) ; scanf( % d, & weekday) ; / / for (i = 1; i < month; i + + ) { / / switch (i) { case 1: case 3: case 5:

89 case 7: case 8: case 10: case 12: num = 31 ; break ; case 4: case 6: case 9: case 11: num = 30 ; break ; case 2: if ( ( year %4 = = 0 & & year %100! = 0 ) year % 400 = = 0 ) num = 29; else num = 28; break; default : n um = 0; yeardays + = num; yea rdays = yeardays + day; / / 1 yeardays = ( yeardays - 1) ; / / weekday = ( yeardays + week day) % 7; printf( % d % d % d % d\ n, year, month, day, weekday) ; : : : , 10 : 1, 1 k : k 2, 3, 4,, k - 1,, k,, k, 2, 3,, k for flag, 1, j 2 k,, k j, flag 0, for,, flag 1, k : flag = 1; for ( i = 2; i < = sqrt( k) ; i + + )

90 if ( k % i = = 0) { flag = 0; break; if ( flag = = 1) printf( %d, k) ;, 100, 100,, k 2 100, for for ( k = 2 ; k < = 100 ; k + + ) { k ;, k;, 10, num,, 1, 10,, : # include < stdio.h > # include < math.h > { int k, j, num = 0, flag; for ( k = 2 ; k < = 100 ; k + + ) { flag = 1; for ( j = 2 ; j < = sqrt( k) ; j + + ) if ( k % j = = 0 ) { flag = 0; break ; if ( flag = = 1) { printf( %3d, k ) ; num + + ; if ( num% 10 = = 0) printf( \ n ) ; printf( \ n 100 %d.\ n, num) ; : e, e = ! + 1 2! + 1 3! + + 1, n! 10-5, : : e = e + term, term,, 1 2! = 1 1! 2, 1 3! = 1 3,,, : term 2! n = t ermn - 1 n, C : term = t erm/ n;, term 1.0, n 1, n n = n + 1, while do - while, term <

91 10-5, count, 0, 1, count, n : 1 : (1 ) while # include < stdio.h > void { int n, count = 0 ; double term, e; e = 1; term = 1.0; n = 1; while (term > = 1e - 5 ) / / 1 e / / / / { term = term/ n; / / n + + ; e = e + term; count + + ; / / / / e / /, 1 printf( e = % lf, = %d \ n, e, count) ; (2 ) do - while # include < stdio.h > { int n = 1, count = 0; double term = 1, e = 0; do { e = e + term; / / e term = term/ n; n + + ; count + + ; while ( term > = 1e - 5) ; e = e + term; / / / / 1 / / printf( e = % lf, = %d \ n, e, count) ; : e = , = 9,, 5.23 ( Fibonacci) 12 : 1,,

92 :, 3, 3, :, : f1 = 1, f2 = 1, fi = fi fi - 2 (i 3 ), = 2, = 3, = 5,, , 12, for : # include < stdio.h > { int f1, f2, f, i; f1 = 1; / / f2 = 1; / / printf( %10d%10d, f1, f2 ) ; for ( i = 3; i < = 12; i + + ) { f = f1 + f2; / / printf( %10d, f) ; if( i % 4 = = 0 ) printf( \ n ) ; / / 4 f1 = f2; / / f2 = f; printf( \ n ) ; : , f = f1 + f2,, f1,, f f2 + f1, f1, f2, f2 : f1 = f1 + f2 ; f2 = f2 + f1 ;,, : # include < stdio.h >

93 int main( ) { int f1, f2, i ; f1 = f2 = 1 ; / / 1 2 printf( %10d%10d, f1, f2 ) ; for ( i = 2; i < = 6; i + + ) { f1 = f1 + f2 ; / / f2 = f2 + f1 ; / / printf( %10d%10d, f1, f2 ) ; if( i % 2 = = 0 ) printf( \ n ) ; / / 4 printf( \ n ) ; 5.24, , 5, 3, 1 3,, :, ;, ;,,? :,,,,,,,, x y z, : (1 ) : x + y + z = 100( ) (2 ) : 5x + 3y + (1/ 3 )z = 100 ( ), 15x + 9y + z = 300, x y z, , 33,, 100, 0 x 20, 0 y 33, 0 z 100, x y z, x y z,, : # include < stdio.h > int main( ) { int x, y, z; for ( x = 0; x < = 20; x + + ) for ( y = 0; y < = 33; y + + ) for (z = 0; z < = 100 ; z + + ) : if( x + y + z = = 100 & & 15 x + 9 y + z = = 300 ) printf( x = % d, y = % d, z = % d\ n, x, y, z) ; x = 0, y = 25, z = 75

94 x = 4, y = 18, z = 78 x = 8, y = 11, z = 81 x = 12, y = 4, z = 84 4, = 72114, x y, z x - y,, x y, 714, : # include < stdio.h > { int x, y, z; for ( x = 0; x < = 20; x + + ) for ( y = 0; y < = 33; y + + ) { z = x - y; if( 15 x + 9 y + z = = 300 ) printf( x = % d, y = % d, z = % d\ n, x, y, z) ;, C, C ( ) {,,, C if switch, if, C if else switch break, while for do - while, while for,, ; do - while,,, for, while do - while break continue, : continue, break

95 1. ( s1 s2 C ), : A. if ( a) s1 ; else s2; B. if (! a) s2; else s1; C. if ( a! = 0) s1; else s2; D. if ( a = = 0 ) s1; else s2 ; 2. { int a = 3, b = 4, c = 5, d = 2; if( a > b ) if( b > c) else printf( % d, d + + ) ; printf( % d, + + d) ; printf( % d\ n, d ) ; A. 2 B. 3 C. 33 D while( x) x : A. x = = 0 B. x = = 1 C. x! = 1 D. x! = 0 4., 5!, A. for (i = 1, p = 1; i < = 5; i + + ) p = i; B. for( i = 1; i < = 5; i + + ){ p = 1 ; p = i; C. i = 1; p = 1; while(i < = 5 ){p = i; i + + ; D. i = 1; p = 1; do{p = i; i + + ; while(i < = 5 ) ; 5. { int i = 0, a = 0 ; while(i < 20) { for ( ; ; ) { if( (i%10) = = 0) break; else i - - ; i + = 11; a + = i; printf( % d\ n, a) ; A. 21 B. 32 C. 33 D. 11 5

96 1. 3, 2.C, if, else if 3. C, if - goto 4., break, continue 5. { int i; for (i = 0; i < 3; i + + ) switch(i) { case 0: printf( %d, i) ; case 2: printf( %d, i) ; default : printf( % d, i) ; 6. { int x = 1, y = 0, a = 0, b = 0; switch ( x) { case 1: switch ( y) { case 0: a + + ; break; case 1: b + + ; break; case 2: a + + ; b + + ; break ; printf( % d %d \ n, a, b) ; 7., while int i = 0; while (i < 10) { if (i < 1) continue ; if (i = = 5) break; i + + ; , { int n, sum = 0 ;

97 n = 1234; do { sum = sum + ( n%10) ( n%10) ; while( n ) ; printf( sum = % d, sum) ; 1. : y = e - x x > 0 ; 1 x = 0, x, y - e x x < 0 2. switch,, ( ) / 2 + 1/ 3-1/ / 99-1/ 100 +, , : (1 ) ; (2 ) ; (3 ) 6. 1, 2, 3, 4 4, ( 4, : 1111,1122, 1212 ). 7., 3,., 153, 153 = ,, m,, 10, ( m )? 10? 10.,

98 6, :, :, ,,,,, 1 000, 1 000, 1 000,, C,,,,,,

99 (1 ),,, C : [ ] ;,,,,, : int n um[ 10] ;, num, 10, num [ 0 ] num [ 1 ] num [9 ], :,, int n; scanf( % d, & n) ; int a[ n ] ; 1 0, 1 (2 ), C ( static), C, : [ ] = { 1, 2,, n;, 0,,, 0,, int n um[ 5 ] = {10, 20,30, 40,50 ; num, num [ 0 ] num [ 1 ] n um [ 2 ] num [ 3 ] num[ 4] ,, VC , int num[ 5] = {10, 20;, num num [ 0 ] = 10, num [ 1 ] = 20, num[ 2] num[ 3] num[ 4] 0, static int num[5 ] = {10,20 ;

100 VC ,, int num [5 ] = {10,, 30, 40, 50; static int num[5 ] = {10,, 30,40, 50;, int num[ ] = {10, 20,30, 40,50 ; num num[ 0] num[ 1] num[ 2 ] num [3 ] num[ 4] 5, : C,,, int num [5 ] ; num[ 5] = {10, 20, 30, 40, 50; 2 C : int num [10] ;, n um 10, num[ 0 ] num [ 9 ], 6.1 num num [0 ] num[1 ] num[2 ] num[ 3] num[4 ] num[ 5] num[ 6] num[ 7] num[ 8] num[ 9] num,, : [ ], [ 0, - 1], int m = 3 ; int a[ 4], b[ 3] = {1,2,3; scanf( % d, a) ; / / a[0] a[1 ] = 10; a[2 ] = b[ m - 1] ; scanf( % d, & a[3 ] ) ; # define size 4 int a[ size], b[ size] ; scanf( % d, & a) ; / / printf( % d, a) ; / / printf( % d, a[ size] ) ; / / b = a ; / / C,

101 , ( ), b = a : a [ size] printf a [ size] size, size, printf a[ size], C 0 size - 1,,,,, , : 10, 10, ( ),, count1 count2, ;, 2, count2 1, count1 1; : # include < stdio.h > { int i, count1 = 0, count2 = 0; int data[ 10 ] ; for (i = 0; i < 10; i + + ) scanf( % d, & data[i] ) ; for (i = 0; i < 10; i + + ) { if( da ta[ i] %2 = = 0) count2 + + ; else count1 + + ; printf( : % d\ n, count2) ; printf( : % d\ n, count1) ; :,? , 6 : # include < stdio.h > { int i; int f[12] = {1, 1; / / for (i = 2; i < 12; i + + ) f[i] = f[i - 2] + f[i - 1 ] ; / /

102 for (i = 0; i < 12; i + + ) { printf( %10d, f[ i] ) ; if( (i + 1 ) %6 = = 0) printf( \ n ) ; / / (1 ), : [ ] [ ] ;,,, 0, int xx [2 ] [ 2] ;, xx 2 2, 4, 1 xx [ 0] [ 0 ] xx [ 0] [ 1 ] 2, 2 xx [1 ] [ 0] xx[ 1] [1 ] 2, 4 (2 ) : [ ] [ ] = {{ 1,, { n, ;, int data[ 2] [3 ] = {{1, 2, 3, {4, 5, 6; data[0 ] [ 0] data[0 ] [ 1] data [0 ] [ 2] data[ 1] [0 ] data[1 ] [ 1] data[1 ] [ 2] VC , (, ),, 0 ( ), int num [3 ] [ 3 ] = {{1, 2, {4, 5, 6;, num [0 ] [ 0] num[ 0] [1 ] num [0 ] [ 2] num [ 1 ] [ 0 ] num [ 1 ] [ 1] num [ 1] [2 ], num [2 ] [ 0] num[ 2] [1 ] num[2 ] [ 2] , int num [3 ] [ 3] = {{1, 2, 3, {, {4, 5, 6; int num [3 ] [ 3] = {{1, 2, 3,, {4, 5, 6; int num [3 ] [ 3] = {{1,, 3, {4, 5, 6; [ ] [ ] = { 1,, n, ;,,, int num[ 2] [2 ] = {1, 2, 3, 4; : num[ 0] [0 ] num [0 ] [ 1] num[ 1] [0 ] num[ 1] [1 ] ,,, int num [3 ] [ 2] = {1, 2, 3, 6;,,, C

103 , int num[ ] [ 3 ] = {1, 2, 3, 4, 5, 6, 7, 8, 9 ;, int num [3 ] [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9; 2,,, 1,, int a[2 ] [ 5 ] ;, a 6.2 a[0 ] [ 0] a[0 ] [ 1] a[ 0] [2 ] a[ 0] [3 ] a[ 0] [4 ] a[ 1] [0 ] a[ 1] [1 ] a[ 1] [2 ] a[ 1] [3 ] a[ 1] [4 ] 6.2 a,, a a[0 ] a[ 1] 2, a[0 ] a[1 ] 5, : a[0 ] : a[ 0] [0 ], a[0 ] [ 1], a[0 ] [ 2], a[ 0] [3 ], a[0 ] [ 4] a[1 ] : a[ 1] [0 ], a[1 ] [ 1], a[1 ] [ 2], a[ 1] [3 ], a[1 ] [ 4], 6.3 : 4 4, :,,,,, : # include < stdio.h > { int i, j, k, a[ 4] [4 ] ; printf( 16! \ n ) ; for (i = 0; i < 4; i + + ) { for (j = 0 ; j < 4 ; j + + ) scanf( % d, & a[i] [j] ) ; printf( \ n : \ n ) ; for (i = 0; i < 4; i + + ) { for (j = 0 ; j < 4 ; j + + ) printf( %5d, a[i] [j] ) ; printf( \ n ) ; printf( : \ n ) ; for (i = 0; i < 4; i + + ) { for (j = 0 ; j < 4 ; j + + )

104 3 { printf( %5d, a[j] [i] ) ; printf( \ n ) ; 3 3, : [ 1 ] [ 2 ] [ 3] ;,, : int x[ 2] [ 2 ] [ 3 ] ;, x 12, : x[ 0] [0 ] [ 0], x[ 0] [0 ] [ 1], x[ 0] [0 ] [ 2], x[ 0] [1 ] [ 0], x[ 0] [1 ] [ 1], x[ 0] [1 ] [ 2] x[ 1] [0 ] [ 0], x[ 1] [0 ] [ 1], x[ 1] [0 ] [ 2], x[ 1] [1 ] [ 0], x[ 1] [1 ] [ 1], x[ 1] [1 ] [ 2], 6.3 1,, : char str [10] ; str, str [ 0 ] str [ 1 ]... str [ 9 ], 10, char str[ 8 ] = { w, e, l, c, o, m, e ;, char str1[ ] = { w, e, l, c, o, m, e ;,,, str [7 ] ;,, str1 7 2 C,,, \ 0, : welcome 7, 8, \0 \0,, welcome 7, char str2 [ 8 ] = { w, e, l, c, o, m, e, \0 ;, str2, str1,

105 , char str2 [ 8 ] = { welcome ;,, char str2 [8 ] = welcome ;, welcome, \ 0, \0, \ 0, 1, : char str3 [ 7] = welcome ;,, \ 0 str3,,,, char str3[ ] = welcome ;,,,, str3 8, \0 3,,, \ 0 : char s1[ 10 ] = { w, e, l, c, o, m, e ; char s2[ 10 ] = welcome ; s1 7,, s2, \0, \ 0 welcome,, \0, s1 s2 w e l c o m e 6.3 s1 w e l c o m e s2,,, ;, \ 0, \ 0, \0, 4,, (1 ) getchar scanf, char str[ 5] ;, for (i = 0; i < 5; i + + ) str[ i] = getchar( ) ;, for ( i = 0; i < 5; i + + ) scanf( % c, & str [i] ) ;, getchar scanf, \ 0,

106 ,,, getchar scanf, (2 ) gets scanf, char xx[ 10] ; gets ( xx ) ; char xx[ 10 ] ; scanf( % s, x x) ; (3 ) putchar printf, for (i = 0; i < 10 ; i + + ) putchar ( xx [i] ) for(i = 0; i < 10; i + + ) printf( % c, xx [i] ) ; (4 ) puts printf, puts ( xx) ; printf( % s, xx) ; 5,, : char name[ 10 ] [ 80 ] ;, name 10, 80 ( 79, \ 0 ),, char str [ 3 ] [ 6 ] = { Tom, Jack, Mike ; char str[ ] [ 6] = { Tom, Jack, Mike ;, 6 5: str[ 0] T o m \ 0 str[ 1] J a c k \ 0 str[ 2] M i k e \ str 6.4, :,, : # include < stdio.h > { char str1 [40], str2[ 20 ] ; int i, k; printf( \ n ) ; scanf( % s, str1) ; printf( \ n ) ; scanf( % s, str2) ; for (i = 0; str1[ i]! = \ 0 ; i + + ) ; for ( k = 0 ; str2 [ k]! = \0 ; k + + ) { str1[i] = str2 [ k] ; i + + ; str1[i] = \ 0 ;

107 printf( % s\ n, str1 ) ; 6.5,,,, :,, ;,, : # include stdio.h # include string.h { char str[ 50 ] ; int i, k, num = 0; printf( please input a string! \ n ) ; scanf( % s, str) ; k = strlen( str) ; for (i = 0; i < k/ 2; i + + ) { if( str[ i] = = str[ k i] ) num + + ; if( num = = k/ 2 ) printf(! ) ; else printf(! ) ; 6.4 C,,,, :, ;,,,,,, : # include < stdio.h > { int i, j, mindata, minid; int xx[ 10 ] = {4, 2, 5, 9, 0, 1, 8, 6, 3, 7 ; for(i = 0; i < 9; i + + ) { mindata = xx [i] ;

108 minid = i; for( j = i + 1; j < 10; j + + ) if( mindata > xx[ j] ) { mindat a = xx[ j] ; minid = j; xx [ minid] = xx [i] ; xx [i] = mindata; for(i = 0; i < 10 ; i + + ) printf( %d, xx[i] ) ; : :10 10,,,,,, 9, 9 : # include < stdio.h > { int i, j, temp; int xx[ 10 ] = {4, 2, 5, 9, 0, 1, 8, 6, 3, 7 ; for(i = 0; i < 10 ; i + + ) for( j = 0; j < 9 - i; j + + ) / /, if( xx [j] > xx [j + 1 ] ) / / {temp = xx[ j] ; xx[j] = xx[ j + 1 ] ; xx [j + 1 ] = temp; for( j = 0; j < 10; j + + ) printf( a[ % d] = % d\ n, j, xx[j] ) ;,, (, ) C, [ 0, - 1] ( : ),,,,, (,,, n n ) C,,, ( ), \ 0,

109 \ 0,,,, \0 1., 2., x[ 1 ] [ 2 ] [ 3 ], 6 3. int a[ 12 ] = {1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12, i = 10;, a[ a [ i] ] 4. char s1 [12] = { string ; char s2 [12] = { string\ n ;, printf ( % d, %d, strlen( s1), strlen( s2 ) ) ; 5. char str [3 ] [ 20 ] = { computer, windows, Unix ;, printf ( % s \ n, str [2 ] ) ;, 6. int a[ ] [4 ] = {5, 6, 8, 7, 2, 4 ;, 7. char str[ ] = { INTEL \ ncpu ;, puts( str) ; ( ) 1. 10,, 2. x [10], Ok, Not Found : 3. x [ 4 ] [4 ],, sum1 sum2, ( ; ) 4., 5. x [4 ] [ 4],, x [0 ] [ 0] x [3 ] [ 3], x[ 0] [1 ] x[ 2] [3 ] 6.,,, 7. 5,

110 7, C :, :,, 7.1 C, main, C, C C,,,,, C 1, (1 ) C,,,, printf scanf getchar putchar

111 (2 ),,, 2, (1 ) ( ) (2 ),, 3, (1 ),, (2 ), ( ) ;, ( ), 4 C,,,, , ANSI C : ( ) { ; ;,,, : 1, 2,,, extern static extern, st atic,, extern

112 ,,,, return ( ) ;, ( ) ( ), return, return ;, void,,, C : ( 1, 2,, n) 1; 2; n ; { ; ;,, 7.1, 4 int max4 (int a, int b, int c, int d) / / { int m1, m2 ; / / if( a > = b ) m1 = a ; / / else m1 = b; if( c > = d) m2 = c; else m2 = d; if( m1 > m2 ) return m1; else return m2; { int x, a1, b1; a1 = 5, b1 = 10 ; x = max4( 12,3 3, a1, b1) ; printf( \ nmax: %d, x) ;, max4 max4,,,,, 4 a b c d, m1 m2

113 , : ( ) ;,,,, printf,,,,,,,, ( ),,, : # include < stdio.h > { int x, y = 2000 ; x = printf( H ere: y = % d,, y) ; printf( x = % d\ n, x) ; printf( Do you understand? \ n ) ; : ( ) H ere: y = 2000, x = 10 Do you understand?,, : ( ), int x; int max4(int u, int v, int s, int t ) ; x = max4 (12, 3 3,5,8 ) ; void,, int x; void s ub (int x1, int x2) ; x = sub (2, 3 ) ; : 2 :,, (1 ) ( ),, (2 ),,, (3 ), return; retur n,, return ( ) ;, (

114 , ) (4 ),, ;, 3, ( ), C,,,,,, 4 : (1 ) : (, ) ; : (, ) ; A NSI C, 7.2,, { float add( float a, float b) ; / / float x, y, z ; printf( \ n input float x, y: ) ; scanf( % f, % f, & x, & y) ; z = add( x, y) ; printf( \ n sum is % f\ n, z) ; float add (float a, float b) { float c ; c = a + b; return c; / / float, float, float add ( float a, float b) ; float add( float, float) ; (2 ) : ( ) ;

115 ANSI C,,, A NSI C,, 7.3 # include < stdio.h > double area( ) ; { double r; printf( input circle s radius: ) ; scanf( % lf, & r) ; / / printf( the circle s area is % f\ n, area( r) ) ; / / double area( double radius ) { return ( radius radius ) ; (3 ) / / area, # include <.h > (4 ),,, : extern (, ) ;,, C ( C99, int) ;,,, (1 ),, max max4 (2 ),, fwrite, (3 ),,, void void exit,

116 ,,, printf,,, return,, :, ;, void : return ; return ( ) ; void return ( ), retur n 7.4 max 3 { int a, b, c; printf( please input a, b: \ n ) ; scanf( % d, % d, & a, & b ) ; c = max(a, b ) ; printf( max = % d\ n, c) ; a = 16; b = 24; / / printf( max = % d\ n, max( a, b) ) ; / / max (a + b, a b) ; max (int x, int y) { if( x > = y) return ( x) ; else return ( y) ; / /, max, main 3 max max, c; max printf, printf ; max, ( ), max, 7.3,,, (1 ),,,,,,,

117 (2 ),,, (3 ),,, C,,, (4 ) C,,, void swap(int a, int b) { a = a + b; b = a - b; a = a - b; printf( \ na = % d, b = % d, a, b) ; / / a = 20, b = 10 { int a = 10, b = 20; swap( a, b) ; printf( \ na = % d, b = % d, a, b) ; / / a = 10, b = 20,, swap, a = 20, b = 10, C,,, a 10, b 20, a b, swap, swap a b, 8, ( ) 7.4 C, 7.4.1,, C :, 7.1 main

新版 明解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

FY.DOC

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

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言語 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++程序设计 - 字符串与格式化输入/输出

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言語入門編『索引』 !... 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

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

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

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

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++ 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

Ps22Pdf

Ps22Pdf ( 98 ) C ( ) ( )158 1998 C : C C C,,, C,, : C ( ) : : (, 100084) : : : 7871092 1/ 16 :18 25 :415 : 2000 3 1 2000 3 1 : ISBN 7 302 01166 4/ T P432 : 00016000 : 22 00 ( 98 ) 20 90,,, ;,,, 1994, 1998, 160,

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 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

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

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

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

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

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

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

プログラムの設計と実現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

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

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 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

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++入門編 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

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

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/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

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

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 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

四川省普通高等学校

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

More information

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

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

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

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

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

More information

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

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

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

科学计算的语言-FORTRAN95

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

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

untitled

untitled MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12

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

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 C C trio@seu.edu.cn C C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 Week3 C Week5 Week5 Memory & Pointer

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

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

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/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

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

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2 Chapter 02 變數與運算式 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.2 2.2.1 2.2.2 2.2.3 type 2.2.4 2.3 2.3.1 print 2.3.2 input 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 + 2.4.6 Python Python 2.1 2.1.1 a p p l e b e a r c 65438790

More information

全国计算机技术与软件专业技术资格(水平)考试

全国计算机技术与软件专业技术资格(水平)考试 全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明

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

新・解きながら学ぶ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

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

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

More information

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

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

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

第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

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

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

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

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

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

VB程序设计教程

VB程序设计教程 高 等 学 校 教 材 Visual Basic 程 序 设 计 教 程 魏 东 平 郑 立 垠 梁 玉 环 石 油 大 学 出 版 社 内 容 提 要 本 书 是 按 高 等 学 校 计 算 机 程 序 设 计 课 程 教 学 大 纲 编 写 的 大 学 教 材, 主 要 包 括 VB 基 础 知 识 常 用 程 序 结 构 和 算 法 Windows 用 户 界 面 设 计 基 础 文 件 处

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

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

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

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

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

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

More information

Microsoft PowerPoint - OPVB1基本VB.ppt

Microsoft PowerPoint - OPVB1基本VB.ppt 大 綱 0.VB 能 做 什 麼? CH1 VB 基 本 認 識 1.VB 歷 史 與 版 本 2.VB 環 境 簡 介 3. 即 時 運 算 視 窗 1 0.VB 能 做 什 麼? Visual Basic =>VB=> 程 式 設 計 語 言 => 設 計 程 式 設 計 你 想 要 的 功 能 的 程 式 自 動 化 資 料 庫 計 算 模 擬 遊 戲 網 路 監 控 實 驗 輔 助 自 動

More information

02

02 Thinking in C++: Volume One: Introduction to Standard C++, Second Edition & Volume Two: Practical Programming C++ C C++ C++ 3 3 C C class C++ C++ C++ C++ string vector 2.1 interpreter compiler 2.1.1 BASIC

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

(\244j\257d\276\307\274\351_201508021-C.indd_70%.pdf)

(\244j\257d\276\307\274\351_201508021-C.indd_70%.pdf) 1847-1852 1872 20 1 1896 8000 20 1896 1950 1 1896 1896 13 1900 1900 3 20 2 4 1910 1950 3 1911 1 2 3 4 1927 4 20 300 6 1906 1930 7 1911 5 1919 8 1914 9 1920 10 11 1902 200 6 12 1930 7 " # #! $! 14 15! "!

More information

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 範 例 試 題 (C++) 試 題 編 號 :11900-920201-4 審 定 日 期 : 94 年 7 月 1 日 修 訂 日 期 : 96 年 2 月 1 日 97 年 1 月 30 日 ( 第 二 部 份 ) 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 應 檢 參 考 資 料 壹 試

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un Linux C July 27, 2016 Contents 1 Linux IDE 1 2 GCC 3 2.1 hello.c hello.exe........................... 5 2.2............................... 9 2.2.1 -Wall................................ 9 2.2.2 -E..................................

More information

untitled

untitled MPICH anzhulin@sohu.com 1 MPICH for Microsoft Windows 1.1 MPICH for Microsoft Windows Windows NT4/2000/XP Professional Server Windows 95/98 TCP/IP MPICH MS VC++ 6.x MS VC++.NET Compaq Visual Fortran 6.x

More information

untitled

untitled 1 7 7.1 7.2 7.3 7.4 7.5 2 7.1 VFT virtual 7.1 3 1 1. 2. public protected public 3. VFT 4. this const volatile 4 2 5. ( ) ( ) 7.1 6. no-static virtual 7.2 7. inline 7.3 5 3 8. this this 9. ( ) ( ) delete

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

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

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

3A 吳嘉詠

3A 吳嘉詠 目 錄 新 詩 散 文 編 者 的 話 1A 蔡 樂 怡 雲 1 3C 葉 楚 甜 珍 貴 的 時 間 25 寫 作 能 抒 發 我 們 心 中 所 感 所 想, 亦 能 帶 給 我 們 無 限 想 像 的 空 間, 突 破 時 空 之 1B 陳 智 霖 蒲 公 英 2 3C 林 景 暉 珍 貴 的 經 驗 33 界 限, 無 遠 而 弗 屆 今 年 的 澂 川 小 集 收 集 各 個 級 別 同

More information

Microsoft PowerPoint - C_Structure.ppt

Microsoft PowerPoint - C_Structure.ppt 結構與其他資料型態 Janet Huang 5-1 結構的宣告 struct 結構名稱 struct 結構名稱變數 1, 變數 2,, 變數 m; struct 結構名稱 變數 1, 變數 2,, 變數 m; student; student; 5-2 1 結構變數初值的設定 struct 結構名稱 struct 結構名稱變數 = 初值 1, 初值 2,, 初值 n student="janet","1350901",100,95

More information

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco Windows RTEMS 1 Danilliu MMI TCP/IP 80486 QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos ecos Email www.rtems.com RTEMS ecos RTEMS RTEMS Windows

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

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

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

More information

导 生 和 被 辅 导 成 员 在 辅 导 过 程 中 的 一 些 不 足 与 可 取 点, 经 过 25 分 钟 的 讨 论, 各 小 组 派 代 表 阐 述 了 各 方 观 点 和 改 进 方 法 然 后, 为 了 改 善 导 生 辅 导 方 法, 让 辅 导 变 得 更 有 效 率, 各 院

导 生 和 被 辅 导 成 员 在 辅 导 过 程 中 的 一 些 不 足 与 可 取 点, 经 过 25 分 钟 的 讨 论, 各 小 组 派 代 表 阐 述 了 各 方 观 点 和 改 进 方 法 然 后, 为 了 改 善 导 生 辅 导 方 法, 让 辅 导 变 得 更 有 效 率, 各 院 西 北 民 族 大 学 大 学 生 学 习 援 助 中 心 助 学 工 作 简 报 2016 年 第 1 期 ( 总 第 十 期 ) 中 心 要 闻 大 学 生 学 习 援 助 中 心 举 办 国 家 计 算 机 二 级 考 试 辅 导 活 动 2016 年 3 月 14 日 19:30 至 21:30, 由 大 学 生 学 习 援 助 中 心 学 业 问 询 小 组 举 办 的 国 家 计 算 机

More information

华恒家庭网关方案

华恒家庭网关方案 LINUX V1.5 1 2 1 2 LINUX WINDOWS PC VC LINUX WINDOWS LINUX 90% GUI LINUX C 3 REDHAT 9 LINUX PC TFTP/NFS http://www.hhcn.com/chinese/embedlinux-res.html minicom NFS mount C HHARM9-EDU 1 LINUX HHARM9-EDU

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

该 奈 自 受 PZ 多 透 soc i e B t h y. y t is NA YL OR exp os ed t h a t b e i n g wh o res or sa in t es s e s we r e m ad e n b ot om. M ean wh i l e NA YL

该 奈 自 受 PZ 多 透 soc i e B t h y. y t is NA YL OR exp os ed t h a t b e i n g wh o res or sa in t es s e s we r e m ad e n b ot om. M ean wh i l e NA YL 探 性 通 性 圣 重 ' 颠 并 格 洛 丽 亚 奈 勒 小 说 贝 雷 的 咖 啡 馆 对 圣 经 女 性 的 重 写 郭 晓 霞 内 容 提 要 雷 的 咖 啡 馆 中 权 社 会 支 配 的 女 性 形 象 美 国 当 代 著 名 黑 人 女 作 家 格 洛 丽 亚 过 对 6 个 圣 经 女 性 故 事 的 重 写 奈 勒 在 其 小 说 贝 覆 了 圣 经 中 被 父 揭 示 了 传 统

More information

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344> 1. 請 問 誰 提 出 積 體 電 路 (IC) 上 可 容 納 的 電 晶 體 數 目, 約 每 隔 24 個 月 (1975 年 更 改 為 18 個 月 ) 便 會 增 加 一 倍, 效 能 也 將 提 升 一 倍, 也 揭 示 了 資 訊 科 技 進 步 的 速 度? (A) 英 特 爾 (Intel) 公 司 創 始 人 戈 登. 摩 爾 (Gordon Moore) (B) 微 軟 (Microsoft)

More information

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1 21 , 7, Windows,,,, : 010-62782989 13501256678 13801310933,,,, ;,, ( CIP) /,,. : ;, 2005. 11 ( 21 ) ISBN 7-81082 - 634-4... - : -. TP316-44 CIP ( 2005) 123583 : : : : 100084 : 010-62776969 : 100044 : 010-51686414

More information

WWW PHP

WWW PHP WWW PHP 2003 1 2 function function_name (parameter 1, parameter 2, parameter n ) statement list function_name sin, Sin, SIN parameter 1, parameter 2, parameter n 0 1 1 PHP HTML 3 function strcat ($left,

More information

数据结构与算法 - Python基础

数据结构与算法 - Python基础 Python 教材及课件 课件及作业见网址 xpzhang.me 1 1. Python 2. 3. (list) (tuple) 4. (dict) (set) 5. 6. 7. 2 Python Python 3 Python 4 Python 1, 100, -8080, 0,... 0x 0-9, a-f 0 xff00, 0 xa432bf 5 1.24, 3.14, -9.80,...

More information

epub83-1

epub83-1 C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C

More information

ebook8-30

ebook8-30 3 0 C C C C C C++ C + + C++ GNU C/C++ GNU egcs UNIX shell s h e l l g a w k P e r l U N I X I / O UNIX shell awk P e r l U N I X C C C C C C U N I X 30.1 C C U N I X 70 C C U N I X U N I X U N I X C Dennis

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 综 合 能 力 考 试 时 间 :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

3. 給 定 一 整 數 陣 列 a[0] a[1] a[99] 且 a[k]=3k+1, 以 value=100 呼 叫 以 下 兩 函 式, 假 設 函 式 f1 及 f2 之 while 迴 圈 主 體 分 別 執 行 n1 與 n2 次 (i.e, 計 算 if 敘 述 執 行 次 數, 不

3. 給 定 一 整 數 陣 列 a[0] a[1] a[99] 且 a[k]=3k+1, 以 value=100 呼 叫 以 下 兩 函 式, 假 設 函 式 f1 及 f2 之 while 迴 圈 主 體 分 別 執 行 n1 與 n2 次 (i.e, 計 算 if 敘 述 執 行 次 數, 不 1. 右 側 程 式 正 確 的 輸 出 應 該 如 下 : * *** ***** ******* ********* 在 不 修 改 右 側 程 式 之 第 4 行 及 第 7 行 程 式 碼 的 前 提 下, 最 少 需 修 改 幾 行 程 式 碼 以 得 到 正 確 輸 出? (A) 1 (B) 2 (C) 3 (D) 4 1 int k = 4; 2 int m = 1; 3 for (int

More information