Ps22Pdf

Size: px
Start display at page:

Download "Ps22Pdf"

Transcription

1 C

2 ( CIP) C /. :, ISBN C C. TP312 CIP ( 2001 ) C * * : /16 : : : ISBN / TP311 :

3 C, C,,,, C,, ( ),, ( ), C C ++ JAVA, C,, C,,,,,,, 1, C, 2 C 3 5 C, C,,, 1

4 C 6 7, 8,, 9, 10, 11 C ASCII C, C,,,, C,,,,,, 1 11,,,,,, 87 ANSI C,,, MS-DOS Windows MS-DOS Turbo C, UNIX C,, : ( ), ( 2 4 ), ( 8 10 ), ( 11 ). ( ),,,,,,,,

5 1 C C C C C C C goto 55 1

6 C main C C C

7 typedef C A ASCII 209 B C 210 C C 210 D C 214 3

8 1 C, C C,, C, C C, 1. 1 C C 1969, ( Bell Laboratories) Ken Thompson D. M. Rithie UNIX 1970, Ken Thompson UNIX, BCPL ( ALGOL 60 CPL ) B 1973, D. M. RithieB C, K. Thompson D. M. Rithie C UNIX 1978, B. W. Kernighan D. M. Rithie The C Programming Language C, CC, C, ( ),, ( ), C 1987, ( ANSI) C 87 ANSI C, 1990, ISO 87 ANSI C ISO C C DOS MS C5. 0 Turbo C 2. 0, UNIX UNIX 4. 2BSD, C C ++ C, C ++ C, C ++ C, C C ++ Borland C ++ Visual C ++ JAVA C, C, 1

9 C C C : C,,, ( 10 % 20% ) C,,, C, C, C C, 34, C, C #, C,,, ( ),,, 1. 2 C C, C C 1. 1 #include stdio. h { printf( Good morning! \ n ) ; printf( * * * * * * * * * * * * * * * \ n ) ; : Good morning! * * * * * * * * * * * * * * *, #include stdio. h, stdio. h, C printf( ), C {, printf( ), 2

10 1 C \n, 1. 2 #include stdio. h / *, C * / { int r; / *, r ( int ) * / float area; / *, area ( float ) * / printf( Input r: ) ; / * r, * / scanf( % d, &r) ; / * scanf( ), r * / area = * r* r; / *, area * / printf( area = % f\ n, area) ; / *, area =, \n * / : Input r: 10 area = :,, / * * /,,, 1. 3 #include stdio. h / *, C * / { int a, b, c; / *, a, b, c int * / int max( int x, int y) ; / * int max, 2, int * / / * * / printf( Input a, b: ) ; / * a, b, * / scanf( % d, % d, &a, &b) ; / * 2 a b, * / c = max( a, b) ; / * max( ), c * / printf( max = % d \ n, c) ; / * c * / int max( int x, int y) / * max( ), int, x, y int * / { int z; / * int z * / if ( x > y) else z = y; z = x; return z; / * z * / : Input a, b: 16, 20 max = 20 2, main max, ( ) max, a, b 3

11 C max x, ymax z C, C : C, 1. 3, C : { ; ;,, C,, ; C, sum, mean, #include, #, ;, / * * /,,, C ( C ) 3 scanf( ) printf( ), 1. 3 max( ),, : ( ) { ; ;, ,,,,,, 4

12 1 C 1. 3,, ( 1 )?,,,,,,,,, , : 1, 100 ; 2,, : 1 ; 2 ; ; 3 ; ; 4 ; 100 ; ; 100, ;, 1 000,,,,,, 100, : sum,,, sum, sum = 0 c, mean,,, n,,, n, n = 0 5

13 C : sum0 ; n0; c; c sum, c + sumsum( ) ; n 1, n + 1n( ) ; n < 100, ( n < ,, n 100, 100, a, ) ; sum /n, mean, sum / nmean; mean,,, , n < 100 n < 1000 ( 2 ), , 1. 2 Y 1. 1 N sum= 0 n= 0 c sum= sum+ c n= n+ 1 n< 100 mean= sum n mean 1. 4 ( ),, ( ), ( ), 1. 2,,, ( ),, 1. 1 sum = 0 n = 0 0 sum sum0 = 0 0 sum sum ,, ch, :

14 1 C ch; ch ( \ n ), ; ch a ch z ch - ( a - A ) ch ch, ch ; ; ch ; ;,, ch 1. 3 : Y 1. 6 s = 3! + 5! + 7! + 9! s, n!, n = 3, 5, 7, 9 s = 0 ; n = 3; s = s + n! ; n = n + 2; n9,, ; s= 0 n= 3 fact( n) s= s+ n! n= n+ 2 n9 s N 1. 4 fact( x) i= 1 m= 1 ix Y m= m* i i= i+ 1 m 1. 6 N 1. 3 s; ch ch n Y Y ch ch ch N N 1. 5 n!? fact( x), x = n, fact ( n ) n! n!, fact( n) fact( x) ( m, i, i = 1, 2, 3,, x) : i = 1; m = 1 ; ix, ; m = m* i; i = i + 1 ; ; m 1. 4 ( 3 ) : 7

15 C,, ( ), 0 1 0, C C, 8 C 3 ( 1 ) 1. 4 C #include stdio. h / *, C * / { int c, n; / *, c, n ( int ) * / float sum, mean; / *, sum, mean ( float ) * / sum = 0; n = 0; / *, * / / * sum n * / do{ / * do{ while * / scanf( % d, &c) ; / * c* / sum = sum + c; / * * / n = n + 1; / * * / while( n < 100) ; / * * / mean = sum / n; / * * / printf( average = % f\ n, mean) ; /*, average =, \ n * / ( 2 ) 1. 5 C #include stdio. h / *, stdio. h, getchar( ) putchar( ) * / { char ch; / * ch ( char ) * / while ( ( ch = getchar( ) )! / * * / = \ n ) / * while, : ch * / { if ( ch >= a&& ch <= z ) / * if * / ch = ch - ( a - A ) ; / * ch, * / putchar( ch) ; / * * / printf( \ n ) ; / * * /

16 1 C : Good morning! GOOD MORNING!, while, {, { ( ), for, {, ( 3 ) 1. 6 C #include stdio. h /*, C * / { int n; /*, n int * / long s, fact( int) ; / * s long, long fact,, int * / for( s = 0, n = 3; n <= 9; n = n + 2) /* for, n = 3, 5, 7, 9, 4 * / s = s + fact( n) ; /* fact( x) * / printf( 3! + 5! + 7! + 9! = % ld \ n, s) ; /* s* / long fact( int x) / * fact( x), long, x int * / { long m = 1; / *, m i long int, m * / int i; / * * / for( i = 1; i < = x; i + + ) / * for, i = 1, 2, 3,, x, x * / m = m* i; / * i * / return m; / * m * / : 3! + 5! + 7! + 9! = long, s m fact int :,,, C, ; C, ; C if for while do-while,, C,,, 9

17 C 1. 4 C, C,,, C : A. ASCII C C,. c, test. c B.,, UNIX. o, MS-DOS. obj, CP / M. CRL,,,, C.,,,,, UNIX. out, MS-DOS. exe, CP/ M. com D.,,,,, C : * * * * * * * * * * * * * * * * * Welcome! * * * * * * * * * * * * * * * * * 1. 2,, 1. 3 s = ,, C 1. 4, :,,,, 64, :! C,? ( 1m ) 1. 5 e ! + 1 2! e ( n n! ),, C C

18 1 C 1. 7 C C C 11

19 2 ( Nikiklaus Wirth) : + =, : C, :, C : int char float double, void C, C, C 12

20 C C C 5 : char intfloat double void void 4 char: 1 1 ASCII int: 2 4 1, PC 2 float: 4 1 double: 8 1 void:,, void, 4, C : signed( ) unsigned( ) long( ) short( ) 4 signed unsigned short long char int, long double Turbo C ++ / bit char unsigned char signed char char int unsigned int unsigned signed int int signed unsigned short int unsigned short signed short int short long int long signed long int long unsigned long int unsigned long float e e + 38 double e e long double e e

21 C signed int,, int ( signed) ( signed) ( unsigned), : 0, ; 1,, short long int, 16 32, short int long int 16 32, long int , int int, int PC, int short int, 2 long C,,, C ( 1 ),, C 0 x, 0, : x = 0 xff; / * 255 * / y = 011; / * 9* /,, 2 : ( short int) ( int) ( long int) ( unsigned),, 2. 1, L U 123L, 4 123U int, 123LU long ( 2 ) C, : ( ), : ; e( E) 1 3, : e e e

22 2,, 4,,, ( bit), ( ), :,, z, 4, #, ( ) C ( ),, 2. 2, ASCII, 1 1, A ASCII 65, A \ 101 \ x41 A, ASCII, 65, 0x41, , 0 255,, A 65, A \0 NULL \ a BELL \ b BS \ f FF \ n NL( LF) \ r CR \ t HT ( TAB) \ v VT \ \ \ \ \ \ddd 1 3 \ xhh C, 15

23 C, This is a test,,,, ASCII C NULL( \0 ), n, n + 1, HELLO 5, 6, : H E L L O \0, a, a a, C,, ( ) C : const ( 1 ), : #define : #define PI PI ,,, #define C, ; PI ( ),, ; ,,,,, ( ), ( 2 ) const ( ) const, const,, : const = ; C, : const double pi = ; piconst ( ), const, 16

24 2 const :,, ;,, #define, const #define const ( ), #define, const,,, #define C ( 1 ) C : C,, C, count, Count, COUNT 3, ANSI ( Turbo C) 31,, 32, 33,, C 3 : 1 ) C : asm, auto, break, case, cdecl, char, const, continue, default, do, double, else, enum, extern, far, float, for, goto, huge, if, interrupt, int, long, near, pascal, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while int, int1 Int INT 2 ) C, ( printf) ( define) C,, 3 ) ( 2 ),,,, 17

25 C, : fmem: free memory available,,,,,,, ( ), 2. 3, selected char c cinchar disk drive; int i ireturnvalue, long l lnumrecs SelectedDiskDrive, string sz szinputstring int array ai aierrornumber,, char * psz pszinputstring, Microsoft Charles Simonyi 2. 3 Microsoft Windows,, Visual Basic Acess,,,,, Microsoft Windows,, C,,, : ;, C, ( ) : int x, y; / * int x, y * / float average; / * float average * / unsigned int z; / * unsigned int z * / double pi; / * double pi * / long m, n; / * long m, n * / 18

26 , : = ; : { int event = 5; char heat = C ; float time = 27. 5; : printf( The winning time in heat % c, heat) ; printf( of event % d was % f., event, time) ; The winning time in heat C of event 5 was 27. 5, C,, printf( ) : printf(, ) ;, : % d % o % x % u % c % s % f printf( ),,,, printf( ), 19

27 C, printf( ),,, : printf ( % s% d \ n, this is a string, 100) ; this is a string 100 printf ( this is a string % d \ n, 100) ; this is a string 100 printf ( % d is int, % f is float. \ n, 10, ) ; 10 is int, is float printf ( % s \ n, HELLO ) ; HELLO scanf( ) C, scanf( ) : scanf (, ) ;, : % d % o % x % c % s % f : & &a &x,, scanf( ), Tab scanf( ) { int a, b; printf( Enter integer a and b: ) ; scanf( % d% d, &a, &b) ; printf( a + b = % d \ n, a + b) ; printf( a - b = % d \ n, a - b) ; : Enter integer a and b: 6 3

28 2 a + b = 9 a - b = 3, scanf ( ) 2,, 2, a b, scanf ( ), : scanf ( % d, % d, &a, &b) ;,, : 6, 3,, & C + ( ) - ( ) * ( ) / ( ) % ( ), C, ++ ( ) - - ( ) ( ), C, /,, 10 / %,,% - 1,, 2. 2 #include < stdio. h > { int x, y; : printf( enter dividend and divisor: ) ; / * * / scanf( % d, % d, &x, &y) ; printf( quotient % d \ n, x / y) ; / * * / printf( remainder % d, x% y) ; / * * / enter dividend and divisor: 23, 5 quotient 4 remainder C, , 21

29 C, 1 1, ++ 1, : x ++ ; ++ x; x = x + 1; x - - ; - - x; x = x - 1; ++ x x + 1, x ++ x + 1 x, - - x x - 1, x - - x - 1 x x = 100, : x ++ x x ++ x - - x x - - x , 2. 3 { int a = 25, b = 80, aa, bb; a ++ ; b--; : aa = ++ a; bb = --b; printf( a = % d, b = % d, aa = % d, bb = % d \n, a, b, aa, bb) ; aa = a ++ ; bb = b--; printf( a = % d, b = % d, aa = % d, bb = % d \n, a, b, aa, bb) ; a = 27, b = 78, aa = 27, bb = 78 a = 28, b = 77, aa = 27, bb = 78, C, C,,, ,,,,,,,,,,, : c = ( ++ a% b-- + c) /d - 6* e : % + / * - =

30 C, C, : 0, 0,, 0, ; 0,,, C 2. 4 C :,, 0 ( ) 1 ( ) 2. 4 C > b > c b c >= b >= c b c == b == c b c <= b <= c b c < b < c b c! = b! = c b c, greater ch1 = A ; ch2 = B ; if ( ch2 > ch1) printf( great than ) ; than, ASCII, B A,, > >= < <= ==! =, x + 8 > y* 10, x + 8 y* 10, , : const float first = 0. 0; const float last = 70. 0; const float small = ; if( ( first + small* 10000) == last) ( first + small* 10000) == last, 1( ),, small ( first + small* ) last, 0( ) : if( abs( first + small* last) < 1e - 6) ( 10-6 ), 23

31 C 2. 7, 3 : ( &&) ( ) (! ),, 1,0 ( 2. 5 ) 2. 5 p q p && q pq! p : 10 > 5 &&! ( 10 < 9) 3 >= 4 C, :! ( ), &&( ), ( ) : a + b > cd &&! e :! + > &&! ( 10 < 9), 1, 10 > 5&&! ( 10 < 9), 1, 3 <= 4, 1( ), if, if #include < stdio. h > { int i; for ( i = 1; i <= 100; i ++ ) if (! ( i% 2) ) printf( % d, i) ; /* i, i% 2 0,! ( i% 2) 1 * / C, C, C : = 24 =, ( ) : a = c ++ ; / * * / b = x* y + 5; / * * /

32 2 e = a > b; / * * /,,, ;,, C : x = y = z = 2; x = ( y = ( z = 2) ) ; z = 2, 2 x, z = 2 2, y, y = z = 2 2, x, 2, : f = a = b + 3; / * f = ( a = b + 3) ; * /, C : if ( ( product = x* y) < 0) else printf( one number is negative \ n ) ; printf( positive product is: % d, product ) ; if, x* y product, 0, 1( ) 0( ) = a + = b a = a + b - = a - = b a = a - b * = a* = b a = a* b / = a / = b a = a / b % = a% = b a = a% b C, 2. 6,, , C

33 C 2. 7 ( ) ( ) int char 8, 8 0 char int int 8 char, int long int int float, double float double double double float float double 2. 9 : C, 3 1? 2: 3 (? ) ( : ) : 1, 0( ), 2 ; 0 ( ), 3 : x = ( a > b)? a: b; / * a b x * / y = ( x >= 0)? x: - x; / * x * / c = ( c >= a&& c <= z )? c - 32: c; / * c * / t? printf( % d, t) : printf( zero entered ) ; / * 0, printf( ), zero entered ;, * /,, : sgn = ( x > 0)? 1: ( x < 0? - 1: 0) /* x, 1, - 1, 0 0 * / , :,, int x = 3, y = 5; float z = 10. 0, a; a = x /y* z 26

34 2 a x / y x y, x / y , C : char short unsigned short long unsigned long float double long double,, 2. 7, ,, : char ch; int i; long l; float f; double d; : result= ( ch i ) + ( f * d ) - ( f + i ) ; int double double int double double double double double result float, float resultresult int, int result : ( ), C,, : ( int) x % n / * x int, * / ( int) sqrt( ( double) n) / * n double, sqrt int * /, ( int) x / y ( int) ( x /y), x, x / y,, : 27

35 C #include < stdio. h > { int i = 3; int j = 4; float f1 = i / j; float f2 = ( float) i / j; printf( 3 /4 = % f or % f depending on the type used. \ n, f1, f2) ; f1 i j,, 0 f2 i j, ( float) i float,, 0. 75,,, : #include < stdio. h > { int i; for( i = 1; i <= 100; ++ i) printf( % d /3 is : % f\ n, i, ( float) i /3) ; ( float),,,, void *, void, malloc ( ) student : struct student * p; p = ( struct student * ) malloc( sizeof( struct student) ) ; 2. 11, : 1, 2,, n, :, : x = ( y = 3, y + 1) ; 28

36 2, y 3, y + 1, 4, 4 ( y = 3, y + 1) x : printf( % d \n, ( 3 + 5, 15) ) ; / * 3 + 5, * / printf( % d, % d \ n, 3 + 5, 15) ; / * * /, C 9,,, : ( ) ( * / % ) ( + - ) ( ) ( < <= > >= ) (! = == ) ( & ) ( && ) (? : ) ( ), C,, 2. 8 C 1 ( ) [ ] - >. 2! * & sizeof 3 * / % < <= > >= 7! = == 8 & && 12 13?: 14 = + = - = * = / = % = & = =! = = = 15,, : a = b + c /d / fun( ) * 5,, : 29

37 C a = b + ( ( ( c / d) / fun( ) ) * 5),, C /*, * / ANSI C,, : / * this is / * an error * / * / Turbo C,, C,,,,,,, ;,, ( ),,,,,,,, C C C,, C, : int a = 3, x; x = a +++ a ++ ; :, a ++ 3, a 4, a ++ 4, a 5, x = 7, 6, a ++, a x = a a ++ ; y = x +++ x; y = a a; z = ++ a +++ a +++ a; x = a +++ a ++ ; : x = a ++ ; x = x + a ++ ; 30 int i = 3; printf( i = % d, i ++ = % d, ++ i = % d \ n, i, i ++, ++ i) ; :,, : i = 3, i ++ = 3, ++ i = 5, :

38 2 i = 5, i ++ = 4, ++ i = 4? PC,,,! C, : a&&b&&c a b c a 0, b c,, a b, a 0, b c,, a b,,,,, : ( a = 5 + 3) ++ b / * 1, a 8, b, 1 * / ( a = 5 + 3) && a > 0++ b / * 1, 1, b, 1 * / ( a = 5 + 3) && a < 0 && ++ b / * a < 0 0, 0, b, 1 * /, ( ),, ++ b, : ( a = 5 + 3) b, b 2. 1 : ( 1 ) x + y% 3* ( int) ( x + y) % 3 /7, x = 4. 2, y = 2. 5 ( 2 ) ( float) ( a + b) /5 + ( int) b% ( int) a, a = 3, b = 4 ( 3 ) a + = a, a - = 2, a* = 2 + 3, a = : ( 1 ) short a = e - 1; ( 2 ) double b = e2. 5 ; ( 3 ) long do = 0xfdaL; ( 4 ) float 2 and = 1 - e : ( 1) #include < stdio. h > { double d; float f; long l; int i; i = f = l = d = 20 / 3; printf( % d % ld % f % f\ n, i, l, f, d) ; ( 2) #include < stdio. h > { int i, j, m, n, s; i = 5; j = 10; m = ++ i; 31

39 C 32 n = j ++ ; s = m ++ - n; printf( i = % d \ tj = % d \ tm = % d \ tn = % d \ ts = % d \n, i, j, m, n, s) ; ( 3) #include < stdio. h > { char c1, c2; int i, j; c1 = a ; c2 = b ; printf( c1 = % c \t% d \ t% o\ t% x\ n, c1, c1, c1, c1) ; printf( c2 = % c \t% d \ t% o\ t% x\ n, c2, c2, c2, c2) ; ( 4) #include < stdio. h > { int x, y, z; x = y = z; z = 3; y = x ++- 1; printf( % d \t% d \ t, x, y) ; y = ++ x - 1; printf( % d \t% d \ n, x, y) ; y = z ; printf( % d \t% d \ t, z, y) ; y = - - z + 1; printf( % d \t% d \ n, z, y) ; 2. 4 ( 1) #include stdio. h ; { float r, s; printf( input the radius: \ n) ; scanf( % f, r) ; ( 2) #include stdio. h s = * r* r; printf( % f\ n, s) ; { int a, b, c, v; / * / * a, b, c are sides* /, / * v is volume of cube* /* / a = 2. 0; b = 3. 0; c = 4. 0 v = a* b* c; printf( % d \ n, v) ; 2. 5 :

40 2 C = 5 9 ( f - 32 ), : F 30, 60, 90, , 2. 8, a b, 2. 9, a, b, c,, 2. 10,, 3

41 3,,, C,, C 3. 1 C C C C 3 ( 1 ) C, : x = 0; /* * / i ++ ; /* * / printf( ) ; /* * /, ( 2 ), : 1 ), : : if else switch( ) : while while( ) 34

42 3 do do while( ) for for( ) 2 ), : continue switch break return goto ( 3 ),,,, ( 4 ) C, {,,, : if ( x < y) { int t; / * t * / t = x; / * t, x y * / x = y; y = t; x y,, :,,,, , 3, 1966, Bohm Jacopini 3, ,, ;,,,,, C, 3 C ; if switch; while, for do while 35

43 C 杂员 再 条件 晕 条件 晕 杂圆 杂员 杂圆 杂员 再 顺序结构选择结构循环结构 if ( 1 ) else if else if : if ( ) ;, else if 3. 2,,, if ;, if if,, : else if 3. 1,, #include < stdio. h > { int choice, value; printf (" Convert: \ n" ) ; / * * / printf (" 1: decimal to hexadecimal \ n " ) ; 36 0

44 3 printf( " 2: hexadecimal to decimal \ n " ) ; printf( " 3: decimal to octal \ n " ) ; printf( " 4: octal to decimal \ n" ) ; printf( " enter your choice: " ) ; scanf( " % d", &choice) ; / * * / if ( choice == 1) / * 1 * / { printf( " enter a decimal value: " ) ; scanf( " % d", &value) ; printf( " % d in hexadecimal is: % x\ n ", value, value) ; if ( choice == 2) / * 2 * / { printf( " enter a hexadecimal value: " ) ; scanf( " % x", &value) ; printf( " % x in decimal is: % d \ n ", value, value) ; if ( choice == 3) / * 3 * / { printf( " enter a decimal value: " ) ; scanf( " % d", &value) ; printf( " % d in octal is: % o\ n ", value, value) ; if ( choice == 4) / * 4 * / { printf( " enter a octal value: " ) ; scanf( " % o", &value) ; printf( " % o in decimal is: % d \ n ", value, value) ; : Convert: 1: decimal to hexadecimal 2: hexadecimal to decimal 3: decimal to octal 4: octal to decimal enter your choice: 3 enter a decimal value: 28 in octal is: 34 if,,, : if ( 2 ) else if else if, if : 37

45 C if ( ) 1; else 2; if 3. 3,,, if 1;, else, else 2 : if, else, if else, 3. 2, #include < stdio. h > { int x; printf( " enter a integer number: " ) ; / * * / scanf( " % d", &x) ; if ( x% 2 == 0) printf( " The number is even \ n " ) ; / * x 2, * / else printf( " The number is odd number \ n " ) ; / * x 2, * / , ( ) if #include < stdio. h > { int a, b; printf (" enter two number: " ) ; scanf (" % d% d", &a, &b) ; if( b) printf (" % f \ n", ( float) a /b) ; / * b 0, float * / else printf (" cannot divide by zero\ n" ) ; / * b 0, * /, if( b) if ( b! = 0) ( 3 ) if if if if, if if else if : if ( x) 38

46 3 if ( y) printf( " 1" ) ; else printf( " 2" ) ; if else? C : else else if,, else if ( y) else if( x), if : if ( x) { if ( y) printf( " 1" ) ; else printf( " 2" ) ; else if( x), if( y) if if_else_if, if_else_if, if,, if, if_else_if, if, 3. 4 #include < stdio. h > { int choice; int value; printf( " Convert: \ n" ) ; printf( " 1: decimal to hexadecimal \ n " ) ; printf( " 2: hexadecimal to decimal \ n " ) ; printf( " 3: decimal to octal \ n " ) ; printf( " 4: octal to decimal \ n" ) ; printf( " enter your choice: " ) ; scanf( " % d", &choice) ; if ( choice == 1) { printf( " enter decimal value: " ) ; scanf( " % d", &value) ; printf( " % d in hexadecimal is: % x\ n ", value, value) ; else if ( choice == 2) { printf( " enter hexadecimal value: " ) ; scanf( " % x", &value) ; printf( " % x in decimal is: % d \ n ", value, value) ; else if ( choice == 3) { printf( " enter decimal value: " ) ; scanf( " % d", &value) ; printf( " % d in octal is: % o\ n ", value, value) ; 39

47 C else if ( choice == 4) { printf( " enter octal value: " ) ; scanf( " % o", &value) ; printf( " % o in decimal is: % d \ n ", value, value) ; switch if_else_if,,, C, switch ( 1 ) switch switch : switch( ) { case 1: 1 case 2: 2 case n: default: n n + 1 switch, case,, case ; case,, switch, default n + 1 default, default,,,, 3 + 5, 4 * 8 switch n default n switch

48 3 switch : if : switch, if switch, case, switch, switch switch switch, switch if_else_if 3. 5 switch #include < stdio. h > { int choice; int value; printf( " Convert: \ n" ) ; /* * / printf( " 1: decimal to hexadecimal \ n " ) ; printf( " 2: hexadecimal to decimal \ n " ) ; printf( " 3: decimal to octal \ n " ) ; printf( " 4: octal to decimal \ n" ) ; printf( " enter your choice: " ) ; scanf( " % d", &choice) ; switch ( choice) { case 1: / * 1 * / printf( " enter decimal value: " ) ; scanf( " % d", &value) ; printf( " % d in hexadecimal is: % x\ n", value, value) ; break; case 2: / * 2 * / printf( " enter hexadecimal value: " ) ; scanf( " % x", &value) ; printf( " % x in decimal is: % d \ n", value, value) ; break; case 3: / * 3 * / printf( " enter decimal value: " ) ; scanf( " % d", &value) ; printf( " % d in octal is: % o \ n", value, value) ; break; case 4: / * 4 * / printf( " enter octal value: " ) ; scanf( " % o", &value) ; printf( " % o in decimal is: % d \ n", value, value) ; break; 41

49 C switch break, switch, switch ( 2 ) default switch default,, switch default : switch( ch) { case Y : case y : printf( " You answered YES! \ n" ) ; break; case N : case n : printf( " You answered NO! \n" ) ; break; switch,?,, default, : default: printf( " Unknown reponse: % d \n", ch) ;,, default default switch,, default, : default: printf( " invalid selection, try again \ n" ) ; ( 3 ) break 3. 5, break switch switch case,, break, switch switch, 1,..., n, n + 1 break, switch n default 2 n n break switch switch break, switch break, :,, break, break, break,, case break 42

50 3, switch, case, break : switch( country) { case China : case Japan : case India : printf( " Asia" ) ; break; case Britan : case France : case German : printf( " Europe" ) ; break; ( 4 ) switch switch switch, switch switch, switch case, : switch( x) { case 1: switch( y) { case 0: printf( " divide by zero error" ) ; break; case 2: break; case 1: process( x, y) ; break; 3. 6 ax 2 + bx + c = 0,, : b = 0 c = 0 a = 0 c0 b0 x = - c / b a0 d = b 2-4ac d0 d < 0 : #include < stdio. h > #include < math. h > 43

51 C { float a, b, c, d, x1, x2, real, imag; printf( " please input a, b, c = " ) ; / * 3 * / scanf( " % f, % f, % f", &a, &b, &c) ; if ( fabs( a) < = 1e - 6) / * a = 0 * / { if ( fabs( b) < = 1e - 6) printf( " error \ n" ) ; / * b = 0 * / else / * b0 * / printf( " The equation has a root: % 6. 2f \n", - c / b) ; else / * a0 * / { d = b* b - 4* a* c; if ( fabs( d) < = 1e - 6) / * d = 0 * / printf( " The equation has two equal roots: % 6. 2f \n", - b / ( 2* a) ) ; else if ( d > 1e - 6) / * d > 0 x1 x2 * / { x1 = ( - b + sqrt( d) ) / ( 2* a) ; x2 = ( - b - sqrt( d) ) / ( 2* a) ; printf( " distinct real roots: % 6. 2f and % 6. 2f \ n", x1, x2) ; else / * d < 0 * / { real = - b / ( 2* a) ; / * * / imag = sqrt( - d) / ( 2* a) ; / * * / printf (" The equation has complex roots: \n) ; / * a + bi * / printf (" % 6. 2f + % 6. 2fi \ n", real, imag) ; printf (" % 6. 2f - % 6. 2fi \ n", real, imag) ; if-else, if-else : ( ) 0, : if ( d == 0)... 0, 0 fabs ( d ) ( 1 e - 6),, d = y = : x ( 0x < 10) 5 x + 3 ( 10x < 20) 3 x - 11 ( 20x < 30) 2 x + 7 ( 30x < 40) 6 x ( x40 ),, 10 ( 0, 10, 20, 30), 10, : 44

52 3 x x / , switch #include < stdio. h > { int x, y, m; printf( " Please input x: " ) ; scanf( " % d", &x) ; if ( x > = 40) m = 4; else m = x /10; switch( m) { case 0: y = x; break; case 1: y = 5* x + 3; break; case 2: y = 3* x - 11; break; case 3: y = 2* x + 7; break; case 4: y = 6* x ; break; default: printf( " The input data is invalid. \ n" ) ; printf( " The result is % d \ n", y) ; 3. 3,,, C C for while do_while for :,, 50, 100,, for ( 1 ) for for : for( 1; 2; 3 ) ; 3,, for 1,, ; 2,, 2 45

53 C ; 3,,, 3 for #include < stdio. h > { int x; for( x = 1; x < = 100; x ++ ) printf( " % d ", x) ;, x 1x 100, printf( ) printf( ), x 1, x 1 00 x 1 0 0, for, x, x for x < = 100, x,, : #include < stdio. h > { int x; for( x = 100; x > 0; x - - ) printf( " % d", x) ;, for 0 99 : #include < stdio. h > { int i; for( i = 0; i < 100; i ++ ) { printf( " this is i: % d", i) ; printf( " and i square: % d \ n", i* i) ; for,, : x = 10; for ( y = 10; y! = x; ++ y) printf( " % d", y) ; printf( " % d", y) ;, x y,,, y 10,

54 3 ( 2 ) for for, 1 ) for,, x y : #include < stdio. h > { int x, y; for ( x = 0, y = 0; x + y < 100; ++ x, y ++ ) printf( " % d", x + y) ; 0 98, x y 1 2 ) for for, 2,, 3,, for 3,, 10: for ( x = 0; x! = 10; ) scanf( " % d", &x) ; 3 ) for, 3, : for ( ; ; ) printf( " this loop will run forever \ n" ) ;,, : for ( ; ; ) if ( scanf( " % d", &x) ) / *, * / printf( " if enter number then this loop will run forever \ n" ) ; else /*, scanf( ), 0, * / break; 4 ) for for, for : for ( t = 0; t < time; t ++ ) ; / * * /, time while ( 1 ) while while : while ( ) ; 47

55 C,,,, for, while,, while 3. 7,, A: wait( ) { char ch; ch = \0 ; / * ch * / while ( ch! = A ) ch = getchar( ) ; while, ch A, ch,,,, A, ch!, = A while, ch,, ch A while, while : while( ( ch = getchar( ) )! ( 2 ) while = A ) ; 3. 7 while, while, for, while?, while 3. 9 #include < stdio. h > { int count = 0; printf( " type in a phrase: \ n" ) ; while ( getchar( )! count ++ ; = \r ) / * * / printf( " \ ncharacter count is % d", count) ; : type in a phrase: cat character count is 3, while for?,,, 48 测试表达式 非园 循环体 憎澡蚤造藻语句的后继语句 0

56 3, while while : ( getchar( )! = \ r ) getchar( ),,,, \ r, \ r, while,, ( 3 ) while while, getchar( ), while ch getchar( ) : #include < stdio. h > { int count = - 1; char ch; printf( " type in a phrase: \ n" ) ; ch = getchar( ) ; while ( ch! = \ r ) { ch = getchar( ) ; count ++ ; printf( " \ ncharacter count is % d", count) ; while,?, ch ch, while, getchar( ) while, C while( 1 ) {,, : while( 1) { ch = getchar( ) ; printf( " \ nthe code for % c id % d. \ n", ch, ch) ;,, : if ( ) break; 非园 循环体 测试表达式 0 憎澡蚤造藻语句的后继语句 3. 8 do while 49

57 C do while ( 1 ) do while do{ ; while ( ) ;,, while do while do while 3. 8 do, do while do, ; while,, do while for while,,, ;, do while do while, 100 do{ scanf( " % d", &num) ; while( num > 100) ; ( 2 ) do_while do?,, do while while, while,, do while,, do while, do while : do{ printf( " convert: \ n" ) ; printf( " 1: decimal to hexadecimal \ n " ) ; printf( " 2: hexadecimal to decimal \ n " ) ; printf( " 3: decimal to octal \ n " ) ; printf( " 4: octal to decimal \ n" ) ; printf( " enter your choice: " ) ; scanf( " % d", &choice) ; while( choice < 1 choice > 4) ;,, 100 : { int count = 1; 50

58 3 int total = 0; do{ total + = count; count + = 2; while( count < 100) ; printf( " total = % d \ n", total) ; ( 1 ) while, a e : #include " stdio. h" #include " conio. h" / * clrscr( ) * / { char ch1, ch2; while ( ( ch1 = getchar( ) )! = EOF) / * ch1, ctrl + z * / { clrscr( ) ; / *, * / printf( " \ ntype in a letter from a to e : \ n" ) ; while ( ( ch2 = getchar( ) )! = ch1) / *, * / { printf( " \ nsorry, % c is incorrect. \ n", ch) ; / * * / printf( " \ ntry again. \ n" ) ; printf( " \ nthat s it! \ n" ) ; / *, * / while EOF( stdio. h ),, ;,,, ( 2 ) C,,, {,,, { Kernighan Ritchie, Allman, Whitesmiths 3 3 1) K&R C ( The C Programming Language), Brian Kernighan Dennis Ritchie, : while( ( c = getchar( ) )! = \ n ) { if ( ( c > = a &&c < = z ) ( c > = A &&c < = Z ) ) { c = c + 4; if ( c > Z &&c < = Z + 4 c > z ) c == c - 26; 51

59 C printf( " % c", c) ; K&R, {,, 2) Allman Allman : while( ( c = getchar( ) )! { = \ n ) if ( ( c > = a &&c < = z ) ( c > = A &&c < = Z ) ) { c = c + 4; if ( c > Z &&c < = Z + 4 c > z ) c == c - 26; printf( " % c", c) ; Allman, {, { 3) Whitesmiths Whitesmiths : while( ( c = getchar( ) )! { = \ n ) if ( ( c > = a &&c < = z ) ( c > = A &&c < = Z ) ) { c = c + 4; if ( c > Z &&c < = Z + 4 c > z ) c == c - 26; printf( " % c", c) ; Allman, Whitesmiths {,,, break continue ( 1 ) break break : break; break switch switch break switch, break,, s = n n

60 3 #include < stdio. h > { int i = 1, s = 0; while( 1) { s + = i* i; if ( s > 1000) / * s, s > 1000 * / break; printf( " n = % d \ n", i - 1) ;,, break ( 2 ) continue continue : continue; continue,, continue , 7 #include < stdio. h > { int s; for( s = 1; s < = 1000; s ++ ) if ( s% 3 == 0) / * 3 * / if( s% 7 == 0) / * 7 * / continue; / *, * / else /* 3, 7 * / printf( " % d ", s) ; continue break continue, break , { int num, c; printf( " input an integer: " ) ; / * * / scanf( " % d", &num) ; 0 测试表达式非园 continue 憎澡蚤造藻语句的后继语句 continue do { c = num% 10; / * 10,, num * / printf( " % d", c) ; / * * / 53

61 C while( ( num / = 10) > 0) ; / * num, 10 * / printf( " \ n" ) ; { int m, n, flag; /* flag, 1, 0 * / printf( " % d ", 2) ; /* 2 * / for( m = 3; m < = 1000; m ++ ) /* m * / { flag = 1; /* flag 1, m * / for( n = 2; n < m; n ++ ) /* n, 2 m - 1 * / if( m% n == 0) /* n m, * / { flag = 0; break; if( flag == 1) printf( " % d", m) ; / *, * / m, m : break n m, flag : ;, n, n sqrt( m) m - 1,, #include " math. h" / * sqrt( ) * / { int m, n, flag; /* flag, 1, 0 * / printf( " % d", 2) ; /* 2 * / for( m = 3; m < = 1000; m + = 2) /* m * / { flag = 1; /* flag 1, m * / for( n = 2; n < sqrt( m) ; n ++ ) / * n, 2 sqrt( m) * / if( m% n == 0) /* n m, * / { flag = 0; break; if( flag == 1) printf( " % d", m) ; / *, * / 3. 4 goto goto goto C,, goto, 1 100, goto : 54

62 3 x = 1; loop1: x ++ ; if ( x < 100) goto loop1; goto : for(... ) { for(... ) { while(... ) { if(... ) goto stop; stop: printf( " error in program. \ n) ; break,,, goto, goto goto,,, goto, goto,, goto , 81, 9 :, : 144( 12* 12) 676( 26* 26), #include < stdio. h > { int n, k, a, b, c; for ( k = 1; ; k ++ ) / * * / { n = k* k; if ( n < 100) continue; / * n, * / if ( n > 999) break; / * n, * / a = n / 100; / * a * / b = ( n - a* 100) /10; / * b * / c = n% 10; / * c * / if (! ( a - b) * ( a - c) * ( b - c) ) / * * / printf( " n = % d = % d* % d \ n", n, k, k) ; 55

63 C s = 1 - #include < stdio. h > { float s = 0. 0, w, f = ; int i; printf( " please input n: " ) ; scanf( " % d", &n) ; for ( i = 0; i < = n; i ++ ) { n - 1 f = ( ) * f; / * f * / w = f / ( 2* i + 1) ; / * w * / s + = w; printf( " the result is % d. ", s) ; : x sin( x) = 0 x0 = 1, 10-6 x n + 1 = x n - f( x n ) f ( x n ), x n + 1 f( x) = 0 f( x) = x sin( x), f ( x) = sin( x) + xcos( x) #include < stdio. h > #include < math. h > { float x1, x0 = 1, f, f1; do{ x1 = x0; /* * / f = x0* sin( x0) ; / * f( x) * / f1 = sin( x0) + x0* cos( x0) ; / * f ( x) * / x1 = x0 - f/ f1; / * * / while( fabs( x1 - x0) > 1e - 6) / * * / printf( " The result is % f6. 2. ", x1) ; 3. 1, 3. 2, 3. 3, 3. 4 : 56

64 , 3 2, 5 3, 7 2,? 3. 6 e = 1 1! + 1 2! n!, ,,, n, 57

65 4 C, C,, ( 1 ), : [ ] ;,, ;,, s name : int s[ 10] ; char name[ 50] ; ( 2 ),,?, : [ ], s[ 5] name[ 33] C, 0, s 9, 10, s[ 0 ] s [ 1 ] s [ 2 ]... s[ 9 ] name 49, 50, name[ 0 ] name[ 49] 58

66 4 :, ( 3 ), C,, s, s 4. 1 s[ 0] s[ 1] s[ 2] s[ 3] s[ 4] s[ 5] s[ 6] s[ 7] s[ 8] s[ 9] 4. 1 s ( 1 ) C,, : [ ] = { ;,,,,, : int s[ 10] = {0, 2, 4, 6, 8, 9, 7, 5, 3, 1 ; 4. 1, #include < stdio. h > #define LIM 5 int table[ LIM] = {50, 20, 10, 5, 1 ; /* table * / { int dex, amount, quantity; printf( " : " ) ; scanf( " % d", &amount) ; for ( dex = 0; dex < LIM; dex ++ ) { quantity = amount /table[ dex] ; printf( " = % 2d, ", table[ dex] ) ; printf( " = % 2d \ n", quantity) ; amount = amount% table[ dex] ; : : 138 = 50, = 2 = 20, = 1 = 10, = 1 = 5, = 1 = 1, = 3 59

67 C , 1, 1, 1 3 : 50 ( amount ), 50 ( ) ;, ( % ) amount, 20 5,, : int table[ LIM] = { 50, 20, 10, 5, 1 ; {,, table [ 0 ] 50, table[ 1 ] 20,, table[ 4] 1 ( 2 ) LIM ( #define 5) : int table[ LIM] = {50, 20, 10, 5, 1 ;,,?, 0 ; : int s[ 10] = {0, 2, 4, 6, 8; s[ 5] s[ 9] 0 : int table[ ] = {50, 20, 10, 5, 1; table? :,,,,, #include < stdio. h > #define N 20 / * 20 * / { int i, max, min, s[ N] ; for( i = 0; i < N; i ++ ) scanf( " % d", &s[ i] ) ; / * s * / max = min = s[ 0] ; / * 1 * / for( i = 1; i < N - 1; i ++ ) / *, * / if ( s[ i] > max) max = s[ i] ; else if ( s[ i] < min) min = s[ i] ; printf( " max = % d, min = % d \ n", max, min) ;

68 fabonacci 20 1, 2 : 1, 1, fabonacci : 1, 1, 2, 3, 5, 8, 13, 21, { int i; int f[ 20] = {1, 1 ; /* f, 1 * / for ( i = 2; i < 20; i ++ ) / * 3, * / f[ i] = f[ i - 1] + f[ i - 2] ; for ( i = 0; i < 20; i ++ ) / * * / { if( i% 5) printf( " \ n" ) ; / * 5 * / printf( " % 12d", f[ i] ) ;,, for, 1 1, ( 1 ) C,, \0 ( 0), 1, 10, : char str[ 11] ;,, \0, ( 2 ) 1 ),, : char s1[ 10] = { H, e, l, l, o, \0 ;, s

69 C S H e 1 1 o \0 \ 0 \0 \0 \0 : 2 ) 4. 2 s1 C,, char s1[ 6] = " Hello" ;, \ 0,,, : char s2[ ] = " This is a string" ; s ,?, scanf( ), : { char name[ 15] ; printf( " Enter your name: " ) ; scanf( " % s", name) ; printf( " Greetings, % s. \ n", name) ; : Enter your name: Mary Greetings, Mary. scanf( ) name \0 : for ( i = 0; i < 5; i ++ ) scanf( " % c", &name[ i] ) ; : name[ 0] = M ; name[ 1] = a ; name[ 2] = r ; name[ 3] = y ; name[ 4] = \ 0 ;, : name = Mary ;, name,, : char name[ 15] = Mary, name1[ 15] ; name1 = name; C,

70 4 ( 1 ) gets( ) gets( ) : gets( ) ;, gets( ),, gets( ) stdio. h, #include < stdio. h > { char str[ 80] ; printf( " enter a string: " ) ; gets( str) ; printf( " % s \ n", str) ; str printf( ), : gets( ),,, gets( ), ( 2 ) C : strcpy ( ) strcat( ) strlen( ) strcmp ( ), : string. h 1 ) strcpy( ) strcpy( ) : strcpy( to, from) strcpy( ) from to to from, hellostr : #include < stdio. h > #include < string. h > { char str[ 80] ; strcpy( str, " hello" ) ; printf( " % s", str) ; 2 ) strcat( ) strcat( ) : 63

71 C strcat( s1, s2) ; strcat( ) s2 s1, s2, hello there : #include < stdio. h > #include < string. h > { char s1[ 20], s2[ 10] ; strcpy( s1, " hello" ) ; strcpy( s2, " there" ) ; strcat( s1, s2) ; printf( " % s", s1) ;, s1, s1 s2, 3 ) strlen( ) strlen( ) : strlen( s) ; s strlen( s) s : #include < stdio. h > #include < string. h > { char str[ 80] ; printf( " enter a string: " ) ; gets( str) ; printf( " % d", strlen( str) ) ;, hi, there, 8 strlen( ) 4 ) strcmp( ) strcmp( ) : strcmp( s1, s2) ; strcmp( ), 0, s1 s2, ; s1 s2, flag , { char s[ 80], password[ ] = A123 ; / * password * / int flag = 0, n = 3; / * flag, 0, n * / do{ printf( " enter password: " ) ;

72 4 gets( s) ; / * * / if (! ( strcmp( s, password) ) / * * / { printf( " OK! \ n" ) ; flag = 1; / * flag 1 * / break; / * * / else if( n > 0) / * * / { printf( " password error, input again! \ n" ) ; while( n > 0) ; if(! flag) n - - ; / * * / { printf( " sorry, you is nt valid user, goodbye! \ n" ) , binary, #include < stdio. h > #include < math. h > #define M 16 { char ch, binary[ M] ; int i, j, dec, ndec, index = 0; / * index binary * / printf( " : " ) ; scanf( " % d", &dec) ; ndec = abs( dec) ; / * dec * / while( dec) { str[ index ++ ] = dec% ; / * * / dec / = 2; binary[ index - - ] = \0 ; / *, index \0 * / for ( i = 0, j = index; i < j; i ++, j - - ) /* * / { ch = binary[ i] ; binary[ i] = binary[ j] ; binary[ j] = ch; printf( " % d : % s \ n", dec, str) ; : : , ( ) 65

73 C #include < stdio. h > main ( ) { int c, i, nwhite, nother, ndigit[ 10] ; / * : nwhite, ndigit[ 10] ndigit[ 0] ndigit[ 9] 0 9, nother* / nwhite = nother = 0; / * 0 * / for ( i = 0; i < 10; ++ i) ndigit[ i] = 0; while( ( c = getchar( ) )! { switch( c) = EOF) { case 0 : case 1 : case 2 : case 3 : case 4 : case 5 : case 6 : case 7 : case 8 : case 9 : ++ ndigit[ c - 0 ] ; / * * / break; case : case \ n : case \ t : ++ nwhite; / * * / break; default: printf( " digits = " ) ; ++ nother; / * * / break for ( i = 0; i < 10; ++ i) printf( " % d", ndigit[ i] ) ; printf( ", white space = % d, other = % d \n", nwhite, nother) ;, int ndigit[ 10] 10 ndigit : if ( c > = 0&& c < = 9 ) c, : c - ndigit 0, 4. 3 C,, :

74 4 [ 1] [ 2] ; [ 1] [ 2] = { ;, 1, 2, a 34( 3 4 ) int : int a[ 3] [ 4] ; 0, a 2, 3,,, ( a ) : a[ 0 ] [ 0 ] a [ 0 ] [ 1 ] a [ 0 ] [ 2 ] a [ 0 ] [ 3 ] a [ 1 ] [ 0 ] a [ 1 ] [ 1 ] a [ 1 ] [ 2 ] a[ 1 ] [ 3 ] a[ 2] [ 0] a[ 2] [ 1] a[ 2] [ 2] a[ 2] [ 3 ], ( ) ( ) a [ 3 ] [ 4] 3 a[ 0] a [ 1 ] a [ 2 ], a [ 0] a[ 1] a[ 2 ] 3 a[ 0 ] 4, a[ 0] [ 0] a[ 0] [ 1 ] a[ 0] [ 2] a[ 0] [ 3] a[ 1] 4, a[ 1] [ 0] a[ 1] [ 1 ] a[ 1] [ 2] a[ 1] [ 3], a[ 2] 4, a[ 2 ] [ 0 ] a[ 2 ] [ 1 ] a[ 2] [ 2] a[ 2] [ 3], : 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 ; 2 : 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 ;, : int a[ ] [ 4] = {{1, 2, {, {0, 10, 11, 12 ; : : 67

75 C [ 1] [ 2] 1, #include < stdio. h > #define M 5 #define N 4 { int i, j, data[ M] [ N] ; for ( i = 0; i < M; i ++ ) / *, i, j * / for ( j = 0; j < N; j ++ ) scanf( " % d", &data[ i] [ j] ) ; for ( i = 0; i < M; i ++ ) / *, i, j * / { for ( j = 0; j < N; j ++ ) printf( " % 8d", &data[ i] [ j] ) ; printf( " \ n" ) ; / * * /,,,, : a[ 1] [ 2] = 3; a[ 2] [ 3] = a[ 1] [ 2] + 5; , : , 61 { char daytab[ 2] [ 13] = { { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, / * * / { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ; / * * / int year, month, day; int i, leap, dayth; /* dayth * / printf( " - - : " ) ; scanf( " % d - % d - % d", &year, &month, &day) ; leap = year% 4 == 0 && year% 100! = 0 year% 400 == 0; / * leap * / dayth = day; for( i = 1; i < month; i ++ ) dayth + = daytab[ leap] [ i] ; printf( " % d % d % d % d ", year, month, day, dayth) ;? daytab

76 4 leap : leap = year% 4 == 0&&year% 100! = 0 year% 400 == 0; 4 100, 400, 1900, 2000 leap 0( ) 1( ), daytab :? 4. 4 C : [ 1] [ 2] [ N] ; [ 1] [ 2] [ N] = { ;, t 223 float : float t[ 2] [ 2] [ 3] ;, 3, 2, 1, : t[ 0] [ 0] [ 0] t[ 0] [ 0] [ 1] t[ 0] [ 0] [ 2] t[ 0] [ 1] [ 0] t[ 0] [ 1] [ 1] t[ 0] [ 1] [ 2] t[ 1] [ 0] [ 0] t[ 1] [ 0] [ 1] t[ 1] [ 0] [ 2] t[ 1] [ 1] [ 0] t[ 1] [ 1] [ 1] t[ 1] [ 1] [ 2], t[ 2] [ 2] [ 3] 22 t[ 0] [ 0] t[ 0] [ 1] t[ 1] [ 0] t[ 1 ] [ 1], 3 2 t[ 0] t[ 1], 2 3,,,, : = 2 160, 4 320, ( 8 ), , 4. 5 C,,,, N, N,, C,, (,! ) { int crash[ 10] ; for ( i = 0; i < 100; i ++ ) crash[ i] = i; 69

77 C, crash 10, 20, 100, 200,,, C?, C, ,,, :, ( ),, ;,,, N N - 1, #include < stdio. h > #define N 20 / * 20 * / { int i, j; int s[ N], t; for( i = 0; i < N; i ++ ) scanf( " % d", &s[ i] ) ; / * s * / for( i = 0; i < N - 1; i ++ ) / *, N - 1 * / for( j = 0; j < N - i - 1; j ++ ) / * * / if ( s[ j] > s[ j + 1] ) / *, * / { t = s[ j] ; s[ j] = s[ j + 1] ; s[ j + 1] = t; for( i = 0; i < N; i ++ ) / * * / printf( " % 10d", s[ i] ) ; ,, 505 mark 50, 50 average 50 : #include < stdio. h > #define M 50 #define N 5 { int mark[ M, N], i, j; float average[ N], t; printf( " : \ n" ) ; printf( " \n" ) ; for( i = 0; i < M; i ++ ) 70

78 4 for( j = 0; j < N; j ++ ) scanf( " % d", &mark[ i] [ j] ) ; for( i = 0; i < M; i ++ ) /* * / { t = 0; /* t * / for( j = 0; j < N; j ++ ) t + = mark[ i] [ j] ; average[ i] = t / N; printf( " \ n" ) ; printf( " " ) ; printf( " " ) ; for( i = 0; i < M; i ++ ) /* * / { for( j = 0; j < N; j ++ ) printf( " % 6d", mark[ i] [ j] ) ; printf( " % 12. 1f\ n", average[ i] ) ; printf( " " ) ; : : : 2, 2 2,, 3 3 3, 5,, 50 :, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,, 97, 98, 99, 100,, 5, 7, 9, 11,, 97, 99,,, 7, 11,, 97 #include < stdio. h > #define M

79 C { int i, p, flag, new, s[ M] ; for( i = 2; i < = M; i ++ ) s[ i] = i; / * s * / p = 0; do{ flag = 0; / * flag, 1 * / while (! flag) / * * / { if ( s[ p]! = - 1) / *,, * / { new = s[ p] ; flag = 1; else p ++ ; / * s[ p] - 1,, * / for( i = p + 1; i < = M; i ++ ) / * new * / if ( ( s[ i]! = - 1) &&( s[ i] % new == 0) ) s[ i] = - 1; while( new < = M/2) ; for( i = 2; i < = M; i ++ ) /* * / if ( s[ i]! = - 1) printf( " % 4d", s[ i] ) ; ( 1) #include < stdio. h > { int a[ 10], i, k = 0; for( i = 0; i < 10; i ++ ) a[ i] = i; for( i = 0; i < 10; i ++ ) k + = a[ i] + i; printf( " % d \ n", k) ; ( 2) #include < stdio. h > { int i, j, row, col, m; int a[ 3] [ 3] == {{1, - 2, 3, {27, 36, 45, { - 56, 47, 89 ; m = a[ 0] [ 0] ; for( i = 0; i < 3; i ++ ) for( j = 0; j < 3; j ++ ) if ( a[ i] [ j] < m) { m = a[ i] [ j] ; row = i; col = j;

80 4 printf( " % d, % d, % d \ n", m, row, col) ; 4. 2, : AZ BY CX az by cx 1 26, i ( 26 - i + 1), 4. 3, s2 s1 strcpy, \0, \0 : 4. 4,, space space paces acesp cespa espac 4. 5, string position, character abcdefgh 5 D, abcddefgh 4. 6 strcmp,,, ASCII : abcdefg abceef, , 4. 8, 4. 9 A + B AB a, 3

81 5 C C,,, C,, C ( 1 ),,,,,, short a , a 2010 a, a a, 5. 1 C,,, pa, a, pa = &a; &, &a a a &a: 2010 a, a, a ; pa, a, apa a a 74

82 5 pa pa = &a a, pa a, a pa pa * pa, *,, 5. 2,, a 2010, a 2010,, pa s a pa ( 2 ) & * 5. 2 & *, &, : &, &a &b[ 2] *, : * pa, &( * px) px, px * ( &x) x, x, & * &a a * pa pa a 5. 3 y = x px = &x; y = * px y = x; px = &x; y = * px; 5. 4 pa = &a * pa = a, x y,,, 5. 3 px = &z, y = * px, y z x pa = &a * pa = a, pa a, a pa, * pa a; pa a, a * pa, ( 5. 5) : px, * pxpx, &pxpx &px 5. 5 px * px px * px &px 75

83 C ( 3 ),,,, ,,, ( 1 ) : * ; : int * pc; / * pc int * / float * pa; / * pa float * / char * name; / * name char * /, : int * pc, * pd, a1, a2; float * pa, d; char * name, * addr, str[ 80] ;, C *, * *,,,,,,,, C, int pc char name, int char ( 2 ), : : : * = ; int * pa = &a, * px = &x; / * pa px, int a x * / float * s = &ss; / * s, float ss * /,, : 76 int n; int * p = &n; :

84 5 int n, * p = &n;, : float x, * p = &x, * q = p;, q p, x, : int * p = 0; int * p = NULL; NULL 0 stdio. h NULL : #define NULL ,,, : &, : int a, * pa; pa = &a; / * pa a * /, : char c, * s1 = &c, * s2; s2 = s1; / * s1 s2 c * /, : char * str, ch[ 80] ; str = ch; / * str ch, str ch * /,, int * p1, * p2, a[ 20] ; p1 = a; p2 = p1 + 5; p1 = p2-3; p1 + = 2; p2 - = 10; int * c, a = 20, * b = &a; float * p; : b = 2000; / * * / p = b; / * * / c = * b; c = a; / * * / 5. 1 a b, #include " stdio. h" 77

85 C {int a, b, * t, * a1 = &a, * a2 = &b; / * a1 a2, a1 a, a2 b * / scanf( " % d, % d", &a, &b) ; if ( a > b) / * a > b a1, a2 * / { t = a1; a1 = a2; a2 = t; / * a1 a2, a1 b, a2 a * / printf( " a = % d, b = % d \ n", a, b) ; printf( " min = % d, max = % d \ n", * a1, * a2) ; : 6, 3 a = 6, b = 3 min = 3, max = , a b, a1 a2, a1, a2,, 5. 6,,,, p : int * p, a = 5; /* p, p, p * / * p = a; /* p, * / pa pb ( ), n, : pa + n, pa - n, pa + +, + + pa, pa - -, - - pa, pa - pb ( 1 ) n, n,, pa short, px long, pa = pa + 1, pa 2; px = px + 1, px 4, p, p n : p ( n ) 78

86 5, p n, C,,, 5. 7, pa a pa a[ i], pa n a[ i] n, * ( pa n) ( 2 ) (! ) pa - 4 pa - 3 pa - 2 pa - 1 pa pa + 1 pa + 2 pa + 3 pa + 4 a[ i - 4] a[ i - 3] a[ i - 2] a[ i - 1] a[ i] a[ i + 1] a[ i + 2] a[ i + 3] a[ i + 4] * ( pa - 4) * ( pa - 3) * ( pa - 2) * ( pa - 1) * pa * ( pa + 1) * ( pa + 2) * ( pa + 3) * ( pa + 4) 5. 7 pa n a,,, int pa, pa n int a a : pa = a; / * pa a * / for( i = 0; i < n; i + + ) { printf( " a[ % d] = % d \ n", i, * pa) ; / * pa * / pa + + ; / * pa * /,, 4 ( y pa ) y = * pa + + ;,, : y = * ( pa + + ), pa, y, pa y = * + + pa; y = * ( + + pa),, pa, pa ( ), y y = ( * pa) + + ;, pa, y, pa y = + + * pa; y = + + ( * pa),, pa,,, y 79

87 C 5. 2 #include " stdio. h" s r {char s[ ] = " Good morning! " char r[ 20], * st, * rt; st = s; rt = r; / * st rt s r * / while ( ( * rt + + = * st + + )! printf( " s string is % s \ n", s) ; printf( " r string is % s\ n", r) ; : s string is Good morning! r string is Good morning! = \0 ) ;, ( * rt + + = * st + + )! = \0 : st rt, \0 st rt,,, st rt s r,, st rt,, \0, while ( ( * rt + + = * st + + )! = \0 ) ; while ( * rt + + = * st + + ) ;, : ( * rt = * st)!? ( 3 ) C,,,,, 5. 8, p q a p q a[ 2 ] a[ 9 ], q - p 7, p - q #include " stdio. h" {char str[ 30], * s; s = str; / * s str * / printf( " Enter a string( less than 30 characters) : \ n" ) ; scanf( " % s", str) ; / * * / while ( * s! = \ 0 ) s + + ; / * s * / printf( " The string length is % d \n", s - str) ; : Enter a string( less than 30 characters) : p q 5. 8 = \0, a[ 2] a[ 3] a[ 4] a[ 5] a[ 6] a[ 7] a[ 8] a[ 9] a

88 5 WINDOWS2000 The string length is 11, s \0 : while ( * s + +! = \0 ) ; while ( * s + + ) ;,,, s?,? , p q, p > q, p q ( ), p = = q 1, p q, p < q, p q p, p = = 0 p! = 0, p = = NULL p! = NULL 5. 3,,, ( 1 ), int a pa, : int a[ 20], * pa; : pa = a; pa = &a[ 0] ; a, a[ 0], pa * pa a[ 0] : int a[ 20], * pa = a;, a[ 5] : pa = &a[ 5] ; * pa a[ 5] ( 2 ),, 3 : 81

89 C, a[ i],, C, a + i a i a[ i], * ( a + i) a[ i], A. pa = a, pa + i pa i a[ i], * ( pa + i) a[ i] B. pa = a, * ( pa + i) a[ i], C pa[ i] pa i, pa a, pa = a ( pa a ), a[ i] : 5. 4 a[ i] * ( a + i) * ( pa + i) pa[ i] #include " stdio. h" {int * p, num[ 4], i; p = num; / * * / for ( i = 0; i < 4; i + + ) * ( p + i) = i + 1; / * * / for ( i = 0; i < 4; i + + ) printf( " num[ % d] = % d \ t", i, num[ i] ) ; / * * / printf( " \ n" ) ; : 82 num[ 0] = 1 num[ 1] = 2 num[ 2] = 3 num[ 3] = #include " stdio. h" 10, data, 10 {float * p, * pend, data[ 10], max, min; * p = * pend = data; / * * / printf( " Enter 10 number: \ n" ) ; for ( i = 0; i < 10; i + + ) scanf(% f, pend ++ ) ; / * pend + +, * / / *, pend data[ 9] * / max = min = * data; / * data[ 0] * / for ( p = data + 1; p < pend; p + + ) / *, p data[ 1] data[ 9] * / if ( * p > max) max = * p; else if ( * p < min) min = * p; printf( " max = % f\ tmin = % f\ n", max, min) ;

90 5 : Enter 10 number: max = min = ,,?,, ;,,,, a p b, a = p a = &b a + + a a- - a a + = n a,, ( 3 ) C,, C, : #include " stdio. h" { char str[ ] = { A, B, C, D, * pc = str, int x = 3191; /* x = 0xc77 * / long y = ; / * y = 0x2412a0 * / printf( " pc[ % d] = % c \ n", 3, * ( pc + 3) ) ; printf( " pc[ % d] = % c \ n", 4, * ( pc + 4) ) ; printf( " pc[ % d] = % c \ n", 8, * ( pc + 8) ) ; 5. 9, str, 4, x ( 2 short ) y ( 4 long ), : pc[ 3] = D pc[ 4] = w pc[ 8] =,,,,,,, pc + 0 str pc + 1 pc + 2 pc + 3 pc + 4 x pc + 5 pc + 6 y pc + 7 pc + 8 pc a,, 5. 10,, a a[ 3 ], a;, a[ 0 ] a[ 1] a[ 2 ],, a[ 0 ] a [ 1 ] a [ 2 ], 83

91 C 4, a a &a[ 0] a [ 0 ] &a [ 0] [ 0 ],, a, &a[ 0 ] a[ 0 ] a[ 0], &a[ 0] [ 0] a[ 0] a[ 1] a[ 2], a[ 0] &a[ 0] [ 0], a[ 1] &a[ 1] [ 0], a[ 2 ] &a[ 2] [ 0], +, : : a[ 0 ] * ( a + 0 ) * a ; a[ i] * ( a + i) ; : ; ;, ; &a[ 1] [ 3] a [ 1 ] + 3 * ( a + 1) + 3 &a[ 2] [ 1] a [ 2 ] + 1 * ( a + 2) + 1 &a[ i] [ j] a[ i] + j * ( a + i) + j, a[ i] [ j] * ( a[ i] + j), * ( * ( a + i) + j) ; i = 0, 1, 2; j = 0, 1, 2, 3, a [ i] * ( a + i), 5. 6 #include " stdio. h" { int a[ 3] [ 4] = {1, 2, 3, 4, 11, 12, 13, 14, 21, 22, 23, 24 ; int i, j; for ( i = 0; i < 3; i + + ) { for( j = 0; j < 4; j + + ) : a[ 0] a[ 1] a[ 2] printf( " % 4d", * ( * ( a + i) + j) ) ; / * a[ i] [ j] * / printf( " \n" ) ; * ( * ( a + i) + j) a[ i] [ j] a a[ 0] [ 0] a[ 0] [ 1] a[ 0] [ 2] a[ 0] [ 3] a[ 1] [ 0] a[ 1] [ 1] a[ 1] [ 2] a[ 1] [ 3] a[ 2] [ 0] a[ 2] [ 1] a[ 2] [ 2] a[ 2] [ 3] a[ 0 ] + 0 a[ 0 ] + 0 a[ 0 ] + 1 a[ 0 ] + 1 a[ 0 ] + 2 a[ 0 ] + 2 a[ 0 ] + 3 a[ 0 ] + 3 a[ 1 ] + 0 a[ 0 ] + 4 a[ 1 ] + 1 a[ 0 ] + 5 a[ 1 ] + 2 a[ 0 ] + 6 a[ 1 ] + 3 a[ 0 ] + 7 a[ 2 ] + 0 a[ 0 ] + 8 a[ 2 ] + 1 a[ 0 ] + 9 a[ 2 ] + 2 a[ 0] + 10 a[ 2 ] + 3 a[ 0] + 11 a, ( ), &a[ 1 ] [ 1] a[ 0 ] + 5 &a[ 0] [ 0] + 5, a + 5, 84

92 5, * ( a + 5) a[ 5], 5. 7 #include " stdio. h" { int a[ 3] [ 4] = {1, 2, 3, 4, 11, 12, 13, 14, 21, 22, 23, 24 ; int * p; p = a[ 0] ; while( p < a[ 0] + 12) printf( ( i% 4)? " % 4d" : " \ n% 4d", * p ++ ) ; 5. 6,,, * p + +, p = a[ 0 ] ; p = a;??,, * ( a[ i] + j) * ( * ( a + i) + j) a[ i] [ j] p, ( * p) [ i] 5. 8 #include " stdio. h" { int a[ 3] [ 4] = {1, 2, 3, 4, 11, 12, 13, 14, 21, 22, 23, 24 ; int ( * p) [ 4], i, j; / * p 4 * / p = a; / * p * / printf( " Enter i, j: " ) ; scanf( " % d, % d", &i, &j) ; printf( " a[ % d, % d] = % d \ n", i, j, ( * p + i) [ j] ) ; : Enter i, j: 2, 3 a[ 2, 3] = 24 t[ 3] [ 4] [ 5], t[ 0] t[ 1] t[ 2 ], 4, 5 ;, t [ 0] t[ 0] [ 0] t[ 0] [ 1] t[ 0] [ 2] t[ 0] [ 3], t[ i] [ j] * ( t[ i] + j), t[ i] [ j] [ k] * ( * ( t[ i] + j) + k) * ( * ( * ( t + i) + j) + k), i = 0, 1, 2; j = 0, 1, 2, 3; k = 0, 1, 2, 3, char, C,, 85

93 C ( 1 ) \0, 5. 9 #include " stdio. h" { char s[ ] = " Good morning! " ; char * p; p = s; /* p s * / printf( " s string is % s\ n", s) ; printf( " ( 1) p string is % s \ n", p) ; p = s + 5; /* p s 5 m * / printf( " ( 2) p string is % s \ n", p) ; : s string is Good morning! ( 1) p string is Good morning! ( 2) p string is morning! % s p s, s ; p s, ( 2 ), : char * str = " I am a student. " ;,, ( 3 ) : char * str; str = " I am a student. " ;,, : char s[ 80] ; s = " I am a student. " ;, str = " I am a student. " ;, 86

94 #include " stdio. h" { char ch, * pc = " C language program. ", * p; printf( " Enter a character: " ) ; scanf( " % c", &ch) ; /* * / p = pc; /* p * / while( * p! = \0&& * p! = ch) /* p * / p + + ; /* p * / if ( * p = = ch) /*,, p * / else printf( " The character % c is % d-th \ n", ch, p-pc + 1) ; printf( " The character not found \ n" ) ; : Enter a character: e The character e is 10-th : Enter a character: s The character not fount #include " stdio. h" #include " string. h" /* ( 1 ) * /, { char str[ 80], * p, * q, t; printf( " Enter a string: " ) ; scanf( " % s", str) ; / * * / for( p = str, q = p + strlen( str) -1; p < q; p + +, q - - ) { t = * p; /*,, p \0 * / / * p, q \ 0,, p q, p, q, p > = q * / * p = * q; * q = t; printf( " The reversed string is: % s \ n", str) ; : Enter a string: abcdefgh / * * /

95 C The reversed string is: hgfedcba strlen( str), str string. h ,, : * [ ] ;,,, p, 3, int : int * p[ 3] ;, : float * px[ 5], * py[ 3], data[ 5] [ 10], a, b, * pa = &a; : int b[ 3] [ 4], * pb[ 3] ; b[ 3] [ 4] b[ 0 ] b[ 1 ] b [ 2] 3, 3 3 : 88 pb[ 0] = b[ 0] ; pb[ 1] = b[ 1] ; pb[ 2] = b[ 2] ; pb #include " stdio. h" { int b[ 3] [ 4], * pb[ 3], i, j; for( i = 0; i < 3; i + + ) / * * / for( j = 0; j < 4; j + + ) b[ i] [ j] = ( i + 1) * ( j + 1) ; pb[ 0] = b[ 0] ; / * 3 * / pb[ 1] = b[ 1] ; pb[ 2] = b[ 2] ; for( i = 0; i < 3; i + + ) / * * / { for( j = 0; j < 4; j + + ) printf( " b[ % d] [ % d] = % d ", i, j, * ( pb[ i] + j) ) ; printf( " \n" ) ;

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

( 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

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

FY.DOC

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

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

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

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

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

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

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

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

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

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

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

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

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

四川省普通高等学校

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

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

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

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

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

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

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

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

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

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

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

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2 WWW PHP 2003 1 Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2 Comments PHP Shell Style: # C++ Style: // C Style: /* */ $value = $p * exp($r * $t); # $value

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

(京)新登字063号

(京)新登字063号 教 育 部 职 业 教 育 与 成 人 教 育 司 推 荐 教 材 Java 程 序 设 计 教 程 ( 第 二 版 ) 沈 大 林 主 编 沈 昕 肖 柠 朴 曾 昊 等 编 著 内 容 简 介 Java 是 由 美 国 SUN 公 司 开 发 的 一 种 功 能 强 大 的, 具 有 简 单 面 向 对 象 分 布 式 可 移 植 等 性 能 的 多 线 程 动 态 计 算 机 编 程 语 言

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

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

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

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

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

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

, 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

科学计算的语言-FORTRAN95

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

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

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

(Microsoft Word - Motion Program \270\305\264\272\276\363 \307\245\301\366 \271\327 \270\361\302\367.doc)

(Microsoft Word - Motion Program \270\305\264\272\276\363 \307\245\301\366 \271\327 \270\361\302\367.doc) : TBFAT-G5MP-MN004-11 1 GX Series PLC Program Manual 2 GX Series PLC Program Manual Contents Contents...3 1... 1-1 1.1... 1-2 1.2... 1-3 1.2.1... 1-3 1.2.2... 1-4 1.2.3... 1-4 1.2.4... 1-6 1.3... 1-7 1.3.1...

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

Microsoft Word - 01.DOC

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

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

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

Microsoft PowerPoint - STU_EC_Ch02.ppt

Microsoft PowerPoint - STU_EC_Ch02.ppt 樹德科技大學資訊工程系 Chapter 2: Number Systems Operations and Codes Shi-Huang Chen Sept. 2010 1 Chapter Outline 2.1 Decimal Numbers 2.2 Binary Numbers 2.3 Decimal-to-Binary Conversion 2.4 Binary Arithmetic 2.5

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

概述

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

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

Microsoft Word - 财务d08z.doc

Microsoft Word - 财务d08z.doc 版 权 所 有 侵 权 必 究 图 书 在 版 编 目 (CIP) 数 据 用 好 Excel(2007 版 ): 财 务 篇 / 王 维, 云 大 勇 编 著. 北 京 : 中 国 宇 航 出 版 社,2007.5 ( 时 尚 IT 生 活 秀 ) ISBN 978-7-80218-208-0 Ⅰ. 用 Ⅱ.1 王 2 云 Ⅲ. 电 子 表 格 系 统,Excel Ⅳ.TP391.13 中 国 版

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

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

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

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

More information

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

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

More information

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

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

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

目录

目录 ALTERA_CPLD... 3 11SY_03091... 3 12SY_03091...4....5 21 5 22...8 23..10 24..12 25..13..17 3 1EPM7128SLC.......17 3 2EPM7032SLC.......18 33HT46R47......19..20 41..20 42. 43..26..27 5151DEMO I/O...27 52A/D89C51...28

More information

untitled

untitled 8086/8088 CIP /. 2004.8 ISBN 7-03-014239-X.... TP313 CIP 2004 086019 16 100717 http://www.sciencep.com * 2004 8 2004 8 1 5 500 787 1092 1/16 16 1/2 391 000 1 2 ii 1 2 CAI CAI 3 To the teacher To the student

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

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

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn Xi III Zebra XI III 1 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn 230V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666

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

6020

6020 6020 ... 1 1.1... 1 1.2... 1 1.3 6020... 2 1.3... 5 1.3.1... 5 1.3.2 ISA I/O (S1)... 5 1.3.3 (J4,5,6)... 6 1.3.4... 6... 9 2.1... 9 2.2... 9 2.3 COMPILING AND LINKING... 11 2.3.1 MICROSOFT C MICROSOFT

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 - 把时间当作朋友(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

untitled

untitled 1 5 IBM Intel 1. IBM 第 1/175 页 第 2/175 页 第 3/175 页 80 第 4/175 页 2. IBM 第 5/175 页 3. (1) 第 6/175 页 第 7/175 页 第 8/175 页 = = 第 9/175 页 = = = = = 第 10/175 页 = = = = = = = = 3. (2) 第 11/175 页 第 12/175 页 第 13/175

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

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM CHAPTER 6 SQL SQL SQL 6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM 3. 1986 10 ANSI SQL ANSI X3. 135-1986

More information

SA-DK2-U3Rユーザーズマニュアル

SA-DK2-U3Rユーザーズマニュアル USB3.0 SA-DK2-U3R 2007.0 2 3 4 5 6 7 8 System Info. Manual Rebuild Delete RAID RAID Alarm Rebuild Rate Auto compare Temp Management Load Default Elapse time Event Log 0 2 3 4 2 3 4 ESC 5

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

提问袁小兵:

提问袁小兵: C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.

More information

/ / (FC 3)...

/ / (FC 3)... Modbus/TCP 1.0 1999 3 29 Andy Swales Schneider aswales@modicon.com ... 2 1.... 3 2.... 3 2.1.. 3 2.2..4 2.3..4 2.4... 5 3.... 5 3.1 0... 5 3.2 1... 5 3.3 2... 6 3.4 / /... 7 4.... 7 5.... 8 5.1 0... 9

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

Ps22Pdf

Ps22Pdf CIP ) / :,2006.2 ISBN 7-80702 - 113-6..........G.206 CIP (2006)080133 :8501168mm 1/ 32 : 120 :2000 2006 3 1 : 5000 ISBN 7-80702 - 113-6/ G206 : 348.00 (16 ) ,?, :,,,,,,,,,!,?,,,,,,?,, ,,,,,,,,,,,,,,,!,!,!

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

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

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor 1 4.1.1.1 (Load) 14 1.1 1 4.1.1.2 (Save) 14 1.1.1 1 4.1.2 (Buffer) 16 1.1.2 1 4.1.3 (Device) 16 1.1.3 1 4.1.3.1 (Select Device) 16 2 4.1.3.2 (Device Info) 16 2.1 2 4.1.3.3 (Adapter) 17 2.1.1 CD-ROM 2 4.1.4

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

( 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

TwinCAT 1. TwinCAT TwinCAT PLC PLC IEC TwinCAT TwinCAT Masc

TwinCAT 1. TwinCAT TwinCAT PLC PLC IEC TwinCAT TwinCAT Masc TwinCAT 2001.12.11 TwinCAT 1. TwinCAT... 3 2.... 4... 4...11 3. TwinCAT PLC... 13... 13 PLC IEC 61131-3... 14 4. TwinCAT... 17... 17 5. TwinCAT... 18... 18 6.... 19 Maschine.pro... 19... 27 7.... 31...

More information

序 软 件 工 程 思 想 林 锐 序 软 件 工 程 思 想 讲 述 软 件 开 发 和 做 程 序 员 的 道 理, 视 野 独 特, 构 思 新 颖, 内 容 风 趣, 不 落 窠 臼, 令 人 耳 目 一 新 堪 称 难 得, 以 至 回 味 无 穷 作 者 从 事 了 八 年 的 软 件 开 发 工 作, 在 他 的 博 士 学 位 论 文 完 成 之 际 写 下 了 这 本 心 之 所 感

More information

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

Computer Architecture

Computer Architecture ECE 3120 Computer Systems Assembly Programming Manjeera Jeedigunta http://blogs.cae.tntech.edu/msjeedigun21 Email: msjeedigun21@tntech.edu Tel: 931-372-6181, Prescott Hall 120 Prev: Basic computer concepts

More information

9,, (CIP) /. :, ISBN T U767 CI P ( 2004 ) : 122 : / mail.whut.edu.c

9,, (CIP) /. :, ISBN T U767 CI P ( 2004 ) : 122 : /    mail.whut.edu.c 9,, (CIP) /. :, 2005.2 ISBN 7 5629 2097 4....T U767 CI P ( 2004 )003594 : 122 : 430070 http:/ / www.techbook.com.cn E-mail: yangxuezh@ mail.whut.edu.cn : : : 7871092 1/ 16 : 17 : 421 : 2005 2 1 : 2006

More information

<4D6963726F736F667420506F776572506F696E74202D20B5DAD2BBD5C228B4F2D3A1B0E6292E707074205BBCE6C8DDC4A3CABD5D>

<4D6963726F736F667420506F776572506F696E74202D20B5DAD2BBD5C228B4F2D3A1B0E6292E707074205BBCE6C8DDC4A3CABD5D> Homeworks ( 第 三 版 ):.4 (,, 3).5 (, 3).6. (, 3, 5). (, 4).4.6.7 (,3).9 (, 3, 5) Chapter. Number systems and codes 第 一 章. 数 制 与 编 码 . Overview 概 述 Information is of digital forms in a digital system, and

More information

,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far address L10: jmp jmp L20: L10 L20

,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far address L10: jmp jmp L20: L10 L20 (Jump) (Loop) (Conditional jump) CMP CALL AND SAR/SHR TEST JMP NOT SAL/SHL Jnnn* OR RCR/ROR LOOP XOR RCL/ROL RETn * nnn, JNE JL -128 127-32,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far

More information

IO

IO 1 C/C++ C FILE* fscanf fgets fread fprintf fputs fwrite C++ ifstream ofstream >>

More information

User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2

User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2 Terminal Mode No User User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2 Mon1 Cam-- Mon- Cam-- Prohibited M04 Mon1 Cam03 Mon1 Cam03

More information

ebook14-4

ebook14-4 4 TINY LL(1) First F o l l o w t o p - d o w n 3 3. 3 backtracking parser predictive parser recursive-descent parsing L L ( 1 ) LL(1) parsing L L ( 1 ) L L ( 1 ) 1 L 2 L 1 L L ( k ) k L L ( 1 ) F i r s

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Fortran Algol Pascal Modula-2 BCPL C Simula SmallTalk C++ Ada Java C# C Fortran 5.1 message A B 5.2 1 class Vehicle subclass Car object mycar public class Vehicle extends Object{ public int WheelNum

More information