C程序设计语言

Size: px
Start display at page:

Download "C程序设计语言"

Transcription

1 C

2 505 1 C B.W.Kernighan, D.M.Ritchie, 2 C 3 C from C Programming Language ---- P ; P20 1-8, 1-9, 1-10; P ; P ; P , 1-22, 1-23; P46 2-3; P49 2-6, 2-8; P58 3-1; P60 3-2; P63 3-3; P64 3-5, 3-6; P71 4-1; P73 4-2; P79 4-4, 4-6, 4-10; P ; P ; P97 5-1, 5-2; P , 5-5; P ; P ; P ; P ; P ,

3 C UNIX C UNIX UNIX Bell Lab K.Thompson D.M.Ritchie 1969 O.S. MIT AE Multies 1970 V1 V2 PDP V3 PDP11/ V4 PDP11/ D.M.Ritchie C C B BCPL CPL 1973 Ritchie Thompson C UNIX 90% V5

4 C 78 C UNIX C C UNIX 78 D.Ritchie C 88 ANSI C C K&R C 88 ANSI C 89 3 CPL BCPL B C C C.Strachey 1969 M.Richards 1970 K.Thompson 1972 D.M.Ritchie 1988 B.Stroustrup

5 C

6 C C C C C

7 1 1 C 1 2 C

8 enum typdef int float char struct union short double long unsigned C

9 { } { } if if else while, do_while, for switch goto, continue, break, return auto static extern register C

10 { } = += *= C 20% 6 C 75%~80% C C C

11 C C PASCAL C

12 1 2 C ,1, 9 a,b, z,a,b, Z _ _ _ + - * / % > < ^ ->. & &&,, >>, <<, =, ==,!=, <=, >=, (, ), [, ],,?, :, {, },,, #, C

13 1.2.2 int auto goto if float static return else char extern break while short register continue for long do unsigned switch double case struct union void enum typedef sizeof const signed default define, undef, include, ifdef, ifndef, endif, line C C

14 1.2.3 C C C main main main C C.C.h C C

15 [ 1-1] /* file: hello.c */ main( ) { printf( hello, world\n ); } /* */ 2. main( ) 3. printf I/O 4. \n C \n \t \b \r \f \\ \ \ \ddd \ PASCAL C

16 [ 1-2] main( ) { /* simple.c */ int a, b, c, sum; a =1; b = 2; } scanf printf scanf( %d, &c); /* */ sum = a + b + c; printf( Sum = %d\n, sum); scanf printf % / %d %d %f %f %c %c %s %s %o %x %% % %d,%f %4d,%6.2f C

17 1.3 C / vi(unix), edit(dos) =>.o.obj.o(.obj) =>.exe C

18 1)UNIX Cc [-o ] [ c] o a.out c.o s1.c, s2.c s3.c C cc c s1.c cc c s2.c cc o s s1.o s2.o s3.c 2)DOS Windows DOS WINDOWS C C VC BC 3 / >, >> C> prog > outfile < C> prog < infile C>prog1 prog2 C

19 C _

20 2 1 2 C [ ] int lower, upper, step; char c, line[100]; extern double x; const double PI = ; const char msg[ ] = Warning ;

21 literal line < 66 ci = * dia; s[i]!= \0 ; #define PAGESIZE 66 #define PI #define ENDSTRING \0 line < PAGESIZE ci = PI * dia; s[i]!= ENDSTRING; \0

22 long 1275, 0127, 0x19a, 0xABD, 123l, 89L , -8E-3, -125e+4 3 A, b,? ASCII IBM EBCDIC ASCII A 65 b \0, \n, \t, \b, \r, \f \\, \, \ddd ( ddd ddd) if( c >= A && c <= Z ) return ( c + a A );

23 4 The C Programming Language \0 0 x x \0

24 UNIX, W32 DOS int short(int) long(int) unsigned(int) float double char 8 8 ANSI C const ---- #define const Volatile ----

25 2 4 int atoi(char s[ ]) { int i, n; n = 0; for(i=0; s[i] >= 0 && s[i] <= 9 ; i++) n = 10*n + s[i] 0 ; return (n); } main( ) { int n; char st[100]; } scanf( %s, st); n = atoi(st); printf( %d\n, n);

26 C int unsigned

27 4 double float long unsign int short, char

28 cast --- < > < > x = sqrt((double) n );

29 2.5 C < >; C PASCAL E1 = E2 C C a = b = c = 0;

30 2 5 1 < > ::= < > < > < > < > < > < > < > < > ::= < > < > < > < > < >( [< > [, < >]* ]) < >

31 < > ::= < > < >[< >] < >.< > < >->< > (< >) *< >

32 1. < > < > < > ::= * &< > -< > +< > ~< >!< > (< >)< > sizeof < > sizeof (< >) ++< > --< > / < >++ < >-- /

33 [ 1] int x, y; int *px; X: 10 Y: 10 x= 10; px = &x; PX: y = *px; ( y = x) - < > &(3), &(x+5) - < > ++

34 [ 2] n = 5; n = 5; x = ++n; x = n++; n 6,? x: 6? x: 5, n: 6

35 [ 3] #include <stdio.h> main( ) { int a, b, c; a = b = c = 0; a = ++b + ++c; } printf( %d %d %d\n,a, b, c); a = b++ + c++; printf( %d %d %d\n,a, b, c); a = ++b + c++; printf( %d %d %d\n,a, b, c); a = b c; printf( %d %d %d\n,a, b, c); a = ++c + c; printf( %d %d %d\n,a, b, c); /* */ /* */ /* */ /* */ /* */

36 2 < > ::= < > < > > < > ::= * / % + - >> << > < >= <= ==!= & ^ &&, *, /, %, +, - >>, << >, <, >=, <=, ==,!= &, ^, &&,

37 [ ] x p n unsigned getbits(unsigned x, unsigned p, unsigned n) { } return ( ( x >> (p + 1 n)) & ~(~0 << n));

38 A && B A B A 0 B 0 A 0 B 0 >> int unsigned 0 << 0 / % e1,e2 e1 e2 e2 a = (t = 3, t+2); 5

39 3 < > ::= < 1>? < 2> : < 3> if( a > b) else z = a; z = b; z = ( a > b)? a: b;

40 4 < > ::= >< > < > ::= = += -= /= %= *= >>= <<= &= ^= = (e1) op= (e2) op (e1) = (e1) op (e2) x += n; x = x+n; [ ] (e1) op= (e2) e1 (e1)=(e1)op(e2) a[++i] *= n a[++i] = a[++i] * n

41 bfreelist_frow->b_back += 2 x += n x = x+n y *= n+1; y = y*(n+1) y = y*n+1

42 ( ) [ ]. -> 2 -! ~ & * ( ) sizeof 3 * / % << >> 6 < <= >= > 7 ==!= 8 & 9 ^ && 12 13? : 14 *= /= %= += -= <<= >>= &= ^= = 15

43 3 1 C

44 1 *x++ = y *= z+3; ++x; --y; 2 goto break; continue; return; return ( ); 3

45 1 { [< >] < >* } } 2 if if_else 3 for while do_while 4 switch case

46 3 2 F if( ) T if( ) F else T 2

47 if else if( n > 0) if(a >b) else z = a; z = b; else else if else if {} if(n > 0){ } else if(a >b) z = a; z = b;

48 if else if if( ) else if( ) else

49 [ 3-1] #include <stdio.h> main( ) { int a, b; char ch; scanf( %d %d, &a,&b); ch = getchar( ); if( ch = = y ){ int x; x = a; a = b; b = x; printf( a = %d b= %d\n, a, b); } else printf( no swap!\n ); }

50 3.3 while while F T

51 [ 3-2] #define EOF 1 main( ) { int c; while(( c = getchar( ))!= EOF) putchar( c ); }

52 [ 3-3] main( ) { } int x = 3; while(x%3!= 2) x +=2; while(x%5!= 4) x += 6; while(x%6!= 5) x += 30; while(x%7!= 0) x += 30; printf( x = %d\n,x);

53 3.4 for for while 2 { 2 2 T F } 3 3

54 for for( i=0; i<10; i++)

55 [ 3-4] int atoi(char s[ ]) { int i, n, sign; for(i=0; s[i] = = s[i] = = \n s[i] = = \t ; i++) ; /* skip white space */ sign = 1; if(s[i] = = + s[i] = = - ) sign = (s[i++] = = + )?1:-1; for(n=0; s[i] >= 0 && s[i] <= 9 ; i++) n = 10*n + s[i] 0 ; return ( sign * n); }

56 [ 3-5] void reverse(char s[ ]) { int c, i, j; for(i=0, j=strlen(s)-1; i < j ; i++,j--){ c = s[i]; s[i] = s[j]; s[j] = c; } } int strlen(char s[ ]) { int i=0; while(s[i]!= \0 ) ++i; return (i); }

57 [ ] for( ; (c = getchar( ))!= EOF; ) for( ; ;) s; s; 2 break return while(a) B; for(; A; ) B;

58 3.5 do_while do while ( ) F while do_while T

59 while(for) do_while [ ] do_while Pascal Repeat untill --- False True

60 [ 3-6] void itoa(int n, char s[ ]) { } int i, sign; if((sign = n) < 0) n = -n; i = 0; do { s[i++] = n% ; } while( (n /= 10 ) > 0); if(sign < 0) s[i++] = - ; s[i] = \0 ; reverse(s); do_while {} while while

61 for while do_while

62 3 6 (switch) switch ( ) case default

63 switch swich { case 1 1 } case 2 2 case n n default n+1 C1 C2 E Cn default S1 S2 Sn Sn+1 1) 2) case 3) 4) default default

64 [ ] 1) 2) switch 3) default default switch 4) case default pascal case switch break; 5) case C switch Pascal case C default

65 [ ] char score; switch(score) { case E : printf( no pass\n ); break; case D : printf( pass\n ); break; case C : printf( better\n ); break; case B : printf( right\n ); break; case A : printf( all right\n ); break; }

66 3.7 break continue goto ; ; return 1 return; 2 return [ ] 1 main return 2 return

67 goto goto goto goto int i, j, k, x; float y; for(i = ) { for(j = ) { for(k = ) { scanf( %d %f, &x, & y); if(x < 0 && y < 0.0) goto inerr; } } } inerr: printf( error in input data!\n );

68 [ 3-7] #define MAXLINE 1000 int getline(char s[ ], int lim); main( ) { } int n; char line[maxline]; while(( n = getline(line, MAXLINE)) > 0) { } while( --n >= 0) if(line[n]!= && line[n]!= \n && line[n]!= \t ) break; line[n+1] = \0 ; printf( %s\n, line);

69 int getline(char s[ ], int lim) { int c, i; for(i=0; i < (lim-1) && (c = getchar( ))!= EOF && c!= \n ; i++) s[i] = c; if( c = = \n ){ s[i] = c; ++i; } s[i] = \0 ; return (i); }

70 [ 3-8] main( ) { int count; char c; count = 0; while(( c = getchar( ))!= EOF){ if( c >= 0 && c <= 9 ) continue; count++; } printf( non digital character: %d\n, count); }

71 [ 3-9] #include <stdio.h> char input[ ] = SSSWILTECH1\1\11W\1WALLMP1 ; main( ) { int i, c; for( i = 2; (c = input[i])!= \0 ; i++){ } switch ( c ) { case a : case 1 : putchar( i ); continue; break; case 1: while( ( c = input[ ++i])!= \1 && c!= \0 ); case 9: case E : case L : default: putchar( S ); continue; putchar( c ); continue; } } putchar( ); putchar( \n ); SWITCH SWAMP

72 2 for( putchar( 1 ); putchar( 2 ); putchar( 3 )){ putchar( 4 ); continue; putchar( 5 ); }

73 3 while(a) { if(b) contine; C; } while(a) if(!b) C;

74 I/O #include <stdio.h> ( getchar, putchar ) #include <math.h> (sin, cos, sqrt ) A B C D

75 ANSI C { [ ] }

76 main ANSI C int void C Pascal procedure function C [ ] C Pascal

77 [ ] C return

78 [ 4-1] x #include <stdio.h> int power(int x, int n); main( ) { } { int i; for (i=0; i <= 10; ++i) printf( %d %d %d\n, i, power(2, i), power(-3, i)); int power(int x, int n) int i, p; p = 1; for(i=1; i<=n; ++i) p = p*x; return (p); }

79 power int power(int x, int n) { int p; for(p = 1; n > 0; --n) p *= x; return (p); }

80 [ 4-2] #define MAXLINE 1000 int index(char s[ ], char t[ ]); int getline(char line[ ], int ml); main( ) { char line[maxline]; while(getline(line, MAXLINE) > 0) if(index(line, the ) >= 0) printf( %s, line); }

81 int index(char s[ ], char t[ ]) { int i, j, k; for(i =0; s[i]!= \0 ; i++){ for(j=i, k=0; t[k]!= \0 && s[j]= = t[k]; j++,k++) ; if(t[k] = = \0 ) return ( i); } return ( -1); }

82 Now is the time for all good men to come to the aid of their party this is the time men to come to the aid of their party

83 4 2 2 ANSI C void C

84 [ 4-3] double atof(char s[ ]) { double val, power; int i, sign; for(i=0; s[i] = = s[i] = = \n s[i] = = \t ; i++) ; sign = 1; if(s[i] = = + s[i] = = - ) sign = (s[i++] = = + )? 1:-1; for(val = 0; s[i] >= 0 && s[i] <= 9 ; i++) val = 10* val + s[i] 0 ; if(s[i] = =. ) i++; for(power=1; s[i] >= 0 && s[i] <= 9 ; i++) { val = 10*val +s[i] 0 ; power *= 10; } return ( sign * val / power); }

85 4 2 3 prototype ANSI C double atof(char s[ ]); double atof( char * );

86 [ 4-4] #define MAXLINE 100 double atof(char s[ ]); int getline( char line[ ], int maxline); main( ) { double sum; char line[maxline]; sum = 0; while(getline(line, MAXLINE) > 0) printf( \t%.2f\n, sum += atof(line)); } [ ]

87 4 2 4 ANSI C float double char short int C Pascal

88 void swap ( int x, int y) { } { } main( ) int temp; temp = x; x = y; y = temp; int a = 2, b = 3; swap(a, b); a b a=2 b=3 swap(a,b) x=2 y=3 swap x=3 y=2

89 a b void swap ( int *px, int *py) { int temp; temp = *px; *px = *py; *py = temp; } main( ) { int a =2, b = 3; &a &b a b } swap ( &a, &b); px py

90 scanf int, char, double C C

91 4 2 5 C (1) x n = 1 n =0 x * x n-1 n > 0 (2) n! = 1 n =0 n * (n-1)! n > 0

92 [ 4-5] n! #include <stdio.h> int fact(int n); main( ) { printf( 3!=%d, 5!=%d\n, fact(3), fact(5)); } int fact(int n) { fact(3) 3*2*1 if( n <= 1) return ( 1); else 3*fact(2) 2*1 return ( n * fact(n-1)); 2*fact(1) } 1 1

93 fact int fact(int n) { int f = 1; While(n){ f *= n; n--; } return ( f); }

94 [ 4-6] (hanoi tower) void hanoi( int n, char x, char y, char z) { } if( n > 0 ) { } main( ) hanoi(n-1, x, z, y); printf( MOVE %d: %c %c\n, n, x, z); hanoi(n-1, y, x, z); { } int n; printf( Please input the number of hanoi tower: ); scanf( %d, &n); hanoi(n, A, B, C ); A B C

95 4 3 C Pascal

96 4 3 1 [ ] auto static extern auto register

97 1)

98 2 C extern extern extern

99 3) static static private ( C++ )

100 4) register 2~3 int, char, short, unsigned register register &

101

102 binary(int x, int y, int n) { int low = 0; int high = n 1; } ANSI C ( ANSI C int x[ ] = { 1, 3, 3, 3}; static char pattern[ ] = the ; static char pattern[ ] = { t, h, e, \0 };

103

104 4 4 C C f( ) { } g( ) { } C if(n > 0) { } int i; /* declare a new */ for(i=0; i<n; i++)

105 [ 4-7] int i = 0; main( ) { int i = 1; printf( i=%d,, i); { int i = 2; printf( i=%d,, i); { i += 1; printf( i=%d,, i); } printf( i=%d,, i); } printf( i=%d\n, i); }?i=1, i=2, i=3, i=3, i=1

106 4. 5 C #define #undef #include #if #ifdef #ifndef #else #endif #line ( # ) C C C #include #define #if

107 4 5 1 include #include #inlcude < > #define

108 #include.h #include s.c f.h r.h #include f.h #include r.h

109 #include.h #include.h #include <stdio.h> #include <math.h> #include local.h

110 4 5 2 #define #define 1 #define YES 1 #define EOF -1

111 #define := = #define then #define begin { #define end ;} Pascal C if( i > 0) then begin a := 1; b:=2; end

112 2) #define #define max(a, B) ((A) > (B)?(A) : (B)) x = max(p+q, r+s); x = ((p+q) > (r+s)? (p+q) : (r+s)); ( a. max(a,b); b. (A)>(B)?(A) : (B) )

113 #define square( x) x * x square(z+1) z+1*z+1 #define square(x) ((x) * (x))

114 #undef YES

115 4 5 3 C #if #ifdef #ifndef

116 #if #else #endif #ifdef YES #else #endif --YES --YES

117 #ifndef THIS #define THIS #endif

118 4 5 4 #line [ ] #line 100 another_name another_name, line 100

119 C

120 5 1 [ ] [ ] [ ] C C

121 1) int a[50]; a[0] ~ a[49] float m[ c - a ], p[2*sizeof(double)]; a[0] a[1]

122 2) char static char mes[ ] = C Language ; char line[100]; 0 ~ N-1 N \0 1

123 3 float y[4][3]; C C y[i][j] y[i,

124 float y[4][3] = { y[0] = { 1, 3, 5 }; } { 1, 3, 5 }, y[1] = { 2, 4, 6 }; { 2, 4, 6 }, y[2] = { 3, 5, 7 }; { 3, 5, 7 }, y[3] = { 0, 0, 0 }; float y[4][3] = { 1, 3, 5, 2, 4, 6, 3, 5, 7 }; C float y[4][3] = { } {1}, {2}, {3}, {4} y[0] = { 1, 0, 0 }; y[1] = { 2, 0, 0 }; y[2] = { 3, 0, 0 }; y[3] = { 4, 0, 0 };

125 main( ) { } float a[4][3], b[3][4], c[4][4]; fun(a, b, c); void fun(float x[ ][3], float y[ ][4], float z[ ][4]; { }

126 [ 5-1] #define MAXLINE 1000 int getline(char line[ ], int maxline); void copy(char s1[ ], char s2[ ]); main( ) /* find longest line */ { } int len; /* current line length */ int max; /* maximum length seen so far */ char line[maxline]; /* current input line */ char save[maxline]; /* longest line saved */ max = 0; while( ( len = getline(line, MAXLINE)) > 0 ) if( len > max ) { } if( max > 0) max = len; copy(line, save); printf( %s, save);

127 void copy( char s1[ ], char s2[ ]) /* copy s1 t o s2 */ { int i = 0; while( ( s2[i] = s1[i] )!= \0 ) i++; }

128 [ 5-2] int day_of_year(int year, int month, int day) { int i, leap; static int day_tab[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 } }; leap = year % 4 = = 0 && year % 100!= 0 year % 400 = = 0; for(i=1; i < month; i++) day += day_tab[leap][i]; return ( day ); }

129 5.2 C C 0 #define NULL 0 C

130 pi = &i; pi i; y = *pi; pi 0x100 i pi=&i pi 0x100 y=*pi y i

131 int *px; char *pc; char *acp[ ]; char (*pac)[ ]; int f( ); int *fpi( ); int (*pfi)( ); int (*p[4][3])( ); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ int *(*pfpi)( ); /* */

132 int x = 100; int *px; px = &x; px x *px px 100 x *px

133 1 int x = 1; int *px; *px = x; 2 char *string; scanf( %s, string); strcpy(string, Hello ); C

134 malloc alloc &

135 2. 1) p p+n p-n p+1 p++ 2) P1 P2 py = px px py strcpy(py, px) 3) = =, >, < 4) p q q p p p q

136 [ ] mid = (low + high ) /2 low mid = low + (high low)/2 mid high

137 p++ p+1 y = *px + 1 y= *(px + 1) y = (*px)++ y = *px ++

138 1. p++ p p+1 p 2. *px+1 px 1 *(px+1) px 1 y= *px+1 = 101 y= *(px+1) = (*px)++ px 1 *px++ px px 1 px 100 px 101 px px 100 px Y=(*px)++ =100 Y=*px++ = 100

139 5 2 2 C 0

140 int a[10], x; int *pa; pa = &a[0]; x = *pa; x = a[0]; x = *a; x = *(pa + 1); x = a[1]; x = *(a+1); x = *(pa+i); x = a[i]; x = *(a+i); pa = &a[0] pa = a; a[i] = *(a+i) pa =a; a = pa ; a++; pa = &a;

141 printf( %d\n, data[i]); printf( %d\n, *data); data[i] *data i data i x + =>

142 C printf( a constant character string\n ); [ ] char *char_ptr, word[20]; char_ptr = point to me ; word = you can t do this ; word

143 int values[100], *inptr = values, i; &values[0] values intptr values[0] *values *intptr &values[i] values+i intptr+i valuse[i] *(values+i) *(intptr+i), intptr[i] values Values values i+1 Values i+1

144 [ 5-3] strlen 1) int strlen( char s[ ]) { } 2) int strlen(char *s) { } int n; for(n=0; *s!= \0 ; s++) n++; return (n); main( ) int n = 0; char st[100]; while(s[n]!= \0 ) scanf( %s, st); ++n; printf( %d\n, strlen(st)); return (n); } char s[ ] { char *s main( ) { char *st; } int l; st = C Language ; l = strlen(st); printf( length=%d\n, l);

145 [ 5-4] strcpy 1) void strcpy(char s[ ], char t[ ]) { } int i = 0; while((s[i] = t[i])!= \0 ) i++; void strcpy(char *s, char *t) { } while((*s = *t)!= \0 ) { } s++; t++; void strcpy(char *s, char *t) { while(*s++ = *t++) ; }

146 5 2 3

147 1) static char days[7][10] = { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] days[0] S u n d a y \0 days[1] M o n d a y \0 days[2] T u e s d a y \0 days[3] W e d n e s d a y \0 days[4] T h u r s d a y \0 days[5] F r i d a y \0 days[6] S a t u r d a y \0

148 2 static char *days[7] = { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; Sunday\0 days[0] Monday\0 days[1] Tuesday\0 days[2] days[3] days[4] Wednesday\0 Thursday\0 days[5] days[6] Friday\0 Saturday\0 char *days[7]

149 #include <stdio.h> a= 0x194, a[0]= 0x194, &a[0][0]= 0x194 char a[4][5] = { abcd, efgh, ijkl, mnop }; a+1= 0x198, a[0]+1= 0x195, &a[0][1]= 0x195 main( ) **(a+1)= e, *(a[0]+1) = b { printf( a=%x, a[0]=%x, &a[0][0]=%x\n, a, a[0], &a[0][0]); printf( a+1=%x, a[0]+1=%x, &a[0][1]=%x\n, a+1, a[0]+1, &a[0][1]); printf( **(a+1)=%c, *(a[0]+1)=%c\n, **(a+1), *(a[0]+1)); } a[0] a[0]+1 a a b c d \0 a+1 e f g h \0 i j k l \0 m n o p \0 a, a[0], &a[0][0] a+1 a[0]+1

150 [ 5-5] char *month_name(int n) { static char *name[ ] = { illegal month, January, February, March, April, May, June, July, August, September, October, November, December }; return ((n<1 n>12)? name[0] : name[n]); }

151 C main int main( int argc, char *argv[ ]) int main( int argc, char **argv) -argc -argv argv[0] argv[1] argv[2] argv[argc-1] argc-1

152 [ 5-6] UNIX each each hello world hello world main( int argc, char *argv[ ]) { } int i; for(i=1; i<argc; i++) printf( %s%c, argv[i], (i< argc-1)? : \n ); main(int argc, char *argv[ ]) { } while(--argc > 0) argv printf((argc > 1)? %s : %s\n, *++argv); each hello world

153 * int (*fp)( ); int *fp( ) = C

154 [ 5-7] int leapyear( int year); main( ) { int (*fnptr)( ); fnptr = leapyear; result = (*fnptr)(2000); } /* leapyear(2000) */ int leapyear( int year) { if(((year % 4 = = 0) && (year % 100!= 0)) (year % 400) = = 0) return ( 1); else return ( 0); }

155 dispatch, index 0~9 index 0 fn0 1 fn1 int fn0( ), fn1( ), fn2( ), fn9( ); static int (*dispatch[ ])( ) = { fn0, fn1, fn2, fn9 }; (*dispatch[index])( );

156 [ 5-8] static char *p[2][3] = { }; abc, defg, hi, jklmnop, qrstuvwxyz, ABCD ***p p[0][0][0] a **p[1] p[1][0][0] j **(p[1]+2) p[1][2][0] A p[1][1][7] x (*(*(p+1)+1))[7] *(p[1][2]+2) p[1][2][2] C

157 [ 5-9] short *pi, *pj, t; long *pl; double *pd; *pd += (double) *pi; pi = &t; *pi = (short) *pl; pj = pi; *pj /= 3; ++pj; ++*pj; pi 1300 t 1350 pj 1380 pl pd

158 5 3 typedef typedef int LENGTH; typedef char *STRING; LENGTH len, maxlen; STRING lineptr[lines], alloc( ); int len, maxlen; char *lineptr[lines], *alloc( );

159 [ 5-10] int (*(*(*test( ))[ ])( )) [ ]; *test( ) typedef int AIN[ ]; *( )[ ] *( ) ( ) int ( ) [ ] typedef AIN *PAIN; typedef PAIN FPAIN( ); typedef FPAIN *PFPAIN; typedef PFPAIN APFPAIN[ ]; typedef APFPAIN *PAPFPAIN; test typedef PAPFPAIN FPAPFPAIN( ); FPAPFPAIN test; [ ]

160 [ 5-11] int (*(*test) ( ))[ ]; *test *( ) ( ) int ( )[ ]; test? typedef int AIN[ ]; typedef AIN *PAIN; typedef PAIN FPAIN( ); typedef FPAIN *PFPAIN; PFPAIN test;

161 [ 5-12] int (*test( ))[ ]; *test( ) int ( ) [ ]; test typedef int AIN[ ]; typedef AIN *PAIN; typedef PAIN FPAIN( ); FPAIN test;

162 typedef

163 C [ ] 1 2 identifier is 3 [x] an array of x ; function returning ; 4 * a pointer to ; 5 go to 3 6 type ;

164 int (*i) ( ); int ( * i ) ( ); i is a pointer to a function returning an int i is a pointer to a function returning an int

165 5 4 enum enum { } enum color { red, green, yellow, white, black }; /* */ enum color chair; enum color suite[10];

166 chair = red; suite[5] = yellow; if( chair = = green ) [ ] C 0 enum color { red, green, yellow = 5, white, black }; red=0, green=1, yellow=5, white=6, black=7 enum Boolean { FALSE, TRUE };

167 ---

168 6 1 struct

169 C Pascal record struct date { int day; int month; int year; int yearday; char mon_name[4]; } type end; date = record day: integer; month: integer; year: integer; yearday: integer; monname: array[0..3] of char; template struct date d1, d2; [ ] struct date struct

170 1 struct { } d; 2 struct date { } d; 3 typdef typedef struct { } DATE; DATE d, *pd, ad[10]; typedef

171 ANSI C static struct date d = { 27, 12, 1984, 361, Dec };

172 struct person { }; char name[namesz]; char address[adrsz]; char department[dpsz]; double salary; struct date birthdate; struct person table[100];

173 [ ] struct keyword { char *name; int count; struct keyword *next; } *base; base 5 int 2 float 4 char struct tnode { } *root; char *word; int count; struct tnode *left; struct tnode *right; root

174 2 struct person emp; emp emp.birthdate.year = 1970; emp.birthdate.month = 8; struct date *pd, d; pd struct date pd = &d pd = (struct date *) malloc(sizeof(struct date)); pd pd pd->year = 1958; strcpy(pd->mon_name, OCT ); pd->year (*pd).year C ->

175 struct { } *p; int x; int *y; ++p->x; x ++(p->x); (++p)->x; (p++)->x; p++->x; *p->y; *p->y++; (*p->y)++; *p++->y; p x x p y y y y p C ( ), [ ],, -> *, ++, --,

176 [ 6-1] #include <stdio.h> main( ) struct { int x; char *y; } *p, A[ ] = { }; 1, for, d d o p 3, for 2, while 3, p_while 4, switch 2, while, 3, do_while, 4, switch { } int i; p = A; printf( %d, ++p->x); printf( %d, ++(p->x)); printf( %d, (p++)->x); printf( %d, p++->x); printf( %c, *p->y); printf( %c, *p->y++); printf( %c, (*p->y)++); printf( %c, *p++->y); for(i=0; i<4; i++) printf( %d, %s\n, A[i].x, A[i].y);

177 6 2 [ 6-2] C

178 6-2 C struct Key { char *keyword; int keycount; } Keytab[ ] = { auto, 0, break, 0, case, 0, while, 0 }; #define MAXWORD 20 #define NKEYS (sizeof(keytab) / sizeof(struct Key)) #define LETTER a #define DIGIT 0 struct Key *binary(char *word, struct Key tab[ ], int n); char getword(char *w, int lim); char type( int c);

179 6-2 main( ) /* count C keyword */ { int t; char word[maxword]; struct Key *p; } while((t = getword(word, MAXWORD))!= EOF) if( t = = LETTER) if(( p = binary(word, Keytab, NKEYS))!= NULL) p->keycount++; for(p=keytab, p < Keytab+NKEYS; p++) if(p->keycount > 0) printf( %4d%s\n, p->keycount, p->keyword);

180 6-2 struct Key *binary(char *word, struct Key tab[ ], int n) { int cond; struct Key *low = &tab[0]; struct Key *high = &tab[n-1]; struct Key *mid; } while(low <= high){ mid = low + (high low) / 2; if((cond = strcmp(word, mid->keyword)) < 0) high = mid 1; else if ( cond > 0) low = mid + 1; else return (mid); } return (NULL);

181 6-2 char getword(char *w, int lim) { int c, t; } if(type(c = *w++ = getch( ))!= LETTER){ *w = \0 ; return ( c); } while(--lim > 0) { t = type(c = *w++ = getch( )); if( t!= LETTER && t!= DIGIT){ ungetch(c); break; } } *(w-1) = \0 ; return ( LETTER);

182 6-2 char type(int c) /* return type of ASCII character */ { if( c >= a && c <= z c >= A && c <= Z ) return ( LETTER ); else if ( c >= 0 && c <= 9 ) return ( DIGIT ); else return (c); }

183 6 3 struct keyword { char *name; int count; struct keyword *next; }; struct tnode { char *word; int count; struct tnode *left; struct tnode *right; };

184 struct link { int n; struct link *next; }; 1) struct link *first *p; p = first = (struct link *)malloc(sizeof(struct link)); p->next = NULL; for(i=0; i<= 10; i++){ p->n = i; p->next = (struct link *)malloc(sizeof(struct link)); p = p->next; } 1 NULL 2 NULL 3 NULL

185 2 p1->next = p->next; p->next = p1; p 1 NULL 2 NULL 3 NULL 3 q = p->next; p1 4 p->next = p->next->next; free(q); p q 1 NULL 2 NULL 3 NULL

186 [ 6-3]

187 [ 6-3] #include <stdio.h> #define MAXWORD 20 struct tnode { char *word; int count; struct tnode *left; struct tnode *right; }; struct tnode *tree(struct tnode *p, char *w); struct tnode *talloc( ); char *strsave(char *s); void treeprint(struct tnode *p);

188 [ 6-3] main( ) /* word frequency count */ { struct tnode *root; char word[maxword]; int t; root = NULL; while((t = getword(word, MAXWORD))!= EOF) if( t = = LETTER) root = tree(root, word); treeprint(root) }

189 [ 6-3] struct tnode *tree(struct tnode *p, char *w) / * install w at or below p */ { int cond; } if( p = = NULL ) { /* a new word has arrived */ p = talloc( ); /* make a new node */ p->word = strsave(w); p->count = 1; p->left = p->right = NULL; } else if((cond = strcmp(w, p->word)) = = 0) p->count ++; /* repeated word */ else if ( cond < 0 ) /* lower into left subtree */ p->left = tree(p->left, w); else /* greater into right subtree */ p->right = tree(p->right, w); return ( p );

190 [ 6-3] struct tnode *talloc( ) { return (( strcut tnode *)malloc(sizeof(struct tnode )); } char *strsave(char *s) { char *p; if((p = malloc(strlen(s)+1))!= NULL) strcpy(p, s); return ( p ); } void treeprint( struct tnode *p) / * print tree p recursirely */ { if(p!= NULL) { treeprint(p->left); printf( %4d%s\n, p->count, p->word); treeprint(p->right); } }

191 [ 6-3] C language book study pascal statement buy C book language buy study pascal statement

192 6 4 int 1 #define O-READ #define O-WRITE #define RW #define HIDE if( status & HIDE ) status = O-READ; 0x01 0x02 0x04 0x08 O_READ O_WRITE RW HIDE

193 2) struct FileStatus { unsigned O_READ:1; unsigned O_WRITE:1; unsigned RW:1; unsigned HIDE:1; }; struct FileStatus status; if(status.hide) status.o_read = 1;

194 struct instruction { unsigned opcode:8; unsigned opert1:4; unsigned opert2:4; }; struct instruction f; opcode opert1 opert

195 & 0

196 6 5 union union { }

197 [ ] union v_tag { int ival; float fval; char *pval; } uval; if(utype = = INT) printf( %d\n, uval.ival); else if (utype = = FLOAT) printf( %f\n, uval.fval); else if(utype = = STRING) printf( %s\n, uval.pval); else printf( bad type\n ); [ ]

198 [ ] struct { char *name; int flags; int utype; union { } uval; int ival; float fval; char *pval; } symtab[nsym]; symtab[i].uval.ival union Pascal

199 : strcu v_tag { int ival; float fval; char *pval; }; union v_tag { int ival; float fval; char *pval; } uval; struct v_tag union v_tag int float char * ival fval pval int ival float fval char* pval struct v_tag union v_tag

200 : union struct 0

201 / UNIX UNIX

202 7 1 / I/O C C I/O I/O UNIX

203 1. / / C / stdio.h #include <stdio.h> I/O int getchar(void) int putchar(int c) char *gets( char *s) int puts( char *s) c s s UNIX

204 [ ] #include <stdio.h> main( ) { } int c; while((c = getchar( ))!= EOF) putchar ( isupper(c)? tolower(c):c); 1 c int; 2 while((c = getchar( ))!= EOF) c=getchar( ) C getchar putchar isupper tolower UNIX

205 [ ] getchar( ) I/O / I/O [ 7-1] #include <stdio.h> main( ) { } int c; while((c = getchar ( ))!= EOF) putchar( c); isn't this <Enter> isn t this CTR+d UNIX

206 prog < infile prog > outfile otherprog prog otherprog prog prog otherprog cat file1 file2 lower > outfile otherprog prog UNIX

207 2 / 1) int scanf( 1 2 ) UNIX

208 scanf %[*][size][l][h]type type (type) d u o x e, f, g c s [ ] [^ ] % char letter[100]; scanf( %[a-z], letter); scanf( %[^,. ;], letter); /* */ /* */ UNIX

209 [ ] int i; float x; cahr name[50]; scanf( %2d %f %*d %2s, &i, &x, name); a72 * size l h type i = 56, x = 789.0, 0123, name = 45 a scanf -1 UNIX

210 2 int printf( 1 2 ) %[flags] [ width] [.prec] [l] type UNIX

211 (type) d u o x a~f X A~F f e e E E f f e f E c s \0 % UNIX

212 flags # 0 0x( 0X) %g %G width * prec e f g s * l type UNIX

213 [ ] int width = 10; printf( %*d, width, result); printf( :%*.*d:\n, 10, 6, 100); : : /* 10 result */ /* 10 6 */ [ ] hello, world 12 :%10s: :%-10s: :hello, world: :hello, world: :%20s: : hello, world: :%-20s: :hello, world : :%20.10s: : hello,wor: :%-20.10s: :hello, wor : :%.10s: :hello, wor: UNIX

214 3 sscanf(char * s, char *format [, pointer ]) s sprintf(char * s, char *format [, arg ]) s scanf printf sprintf main( ) { char buf[100], *cmd= pr -w, *file= /tmp/data ; int width = 80; sprintf(buf, %s %d %s, cmd, width, file); printf( %s\n, buf); } sscanf char *buf = ; float val1, val2; char oper; sscanf(buf, %f %c %f, &val1, &oper, &val2); UNIX

215 3 / #include <stdio.h> 1) fopen( ); 2) getc, putc, fgetc, fputc, fgets, fputs, fscanf, fprintf 3) fclose( ); UNIX

216 fopen FILE *fopen(const char *filename, const char *mode); fopen FILE fopen FILE *fp; FILE struct fopen fopen( ) FILE FILE UNIX

217 fopen fp = fopen( ) r w a r+ w+ a+ UNIX

218 w a fopen w a r NULL r+ w+ r+ a+ rb w+b [ ] UNIX

219 getc( fp ), putc(c, fp) fgetc(fp), fputc(c, fp) fscanf(fp, format, ), fprintf(fp, format, ) / FILE stdin, stdout, stderr getc, putc fgetc,fputc fgetc fputc getc putc stdio.h #define getchar ( ) getc(stdin) #define putchar(x) putc(x, stdout) UNIX

220 [ 7-2] cat x.c y.c z.c #include <stdio.h> void filecopy(file *fp); main( int argc, char *argv[ ]) { FILE *fp; if( argc = = 1) filecopy(stdin); else while(--argc > 0) if(( fp = fopen(*++argv, r )) = = NULL) { printf( cat: can t open %s\n, *argv); break; } } else { filecopy(fp); fclose(fp); } void filecopy( FILE *fp) { int c; while((c = getc(fp))!= EOF) putc(c, stdout); } UNIX

221 4 exit(1), exit(0) exit fclose _exit UNIX

222 [ ] cat main( int argc, char *argv[ ]) { FILE *fp; if( argc = = 1) filecopy(stdin); else while(--argc > 0) if(( fp = fopen(*++argv, r )) = = NULL) { printf( cat: fprintf(stderr, can t cat: open can t %s\n, open %s\n, *argv); *argv); break; exit(1); } else { filecopy(fp); fclose(fp); } } exit(0); UNIX

223 5 / char *fgets(char *s, int n, FILE *fp) fp n-1 s s NULL int fputs( char *s, FILE *fp) s \n fp EOF fgets s gets fputs fgets fgets gets fgets(buf, 81, stdin); UNIX

224 6 / size_t fread(void *ptr, size_t size, size_t nobj, FILE *fp) fp size nobj ptr size_t fwrite(const void *ptr, size_t size, size_t nobj, FLE *fp) ptr fp size nobj fread(buf, sizeof(struct Date), n, fp); fwrite(buf, sizeof(struct Date), n, fp); UNIX

225 7 2 #include <ctype.h> isalpha(c) c 0 0 isupper(c) islower(c) #define isupper(c ) (c >= A && c<= Z )?1:0 isdigit(c) isspace(c) toupper(c) tolower(c) c 0 0 c c UNIX

226 ungetc(c, fp) #include <stdio.h> c fp #include <stdlib.h> system(s) s system( date ); #include <stdlib.h> void *malloc(size_t size); void *calloc(size_t nobj, size_t n); void free(void *p); int *ip; ip = (int *) malloc(100*sizeof(int)); UNIX

227 #include <string.h> char *strcpy(char *s1, char *s2); char *strcat(char *s1, char *s2); int strcmp(char *s, char *t); int strlen(char *s); char st[20], *p= c language ; char *strchr(char *s, char c); char *strstr(char strcpy(st, *s1, char p); *s2); int feof(file *fp) 0 int fseek(file *fp, long offset, int origin) origin offset origin SEEK_SET SEEK_CUR SEEK_END fseek(fp, 0, SEEK_SET); long ftell(file *fp) fseek(fp, -5, SEEK_END); 5 UNIX

228 #include <stdlib.h> double atof(const char *s); int atoi(const char *s); long atol(const char *s); UNIX

229 7 3 UNIX / 1 UNIX / UNIX file descriptor [ ] UNIX

230 2 1) open creat 2) open fopen open 3) fopen creat fd = creat( char *name, int perms); name perms UNIX 9 bit rwx rwx rwx -1 UNIX

231 4) open #include <fcntl.h> (DOS io.h ) int fd; int open(char *name, int flags); fd = open(name, flags); name flags O_RDONLY O_WRONLY O_RDWR O_NDELAY O_APPEND O_TRUNC ( 0) 1 2 O_CREAT -1 UNIX

232 5) close(fd); 6) unlink(filename); UNIX

233 3. nr = read( ) nw = write( ) 1) read nr 0-1 2) write nw ) UNIX

234 [ ] #include <fcntl.h> #define BUFSIZE 512 main( ) { char buf[bufsize]; int n; } while((n = read(0, buf, BUFSZIE)) > 0) write(1, buf, n); UNIX

235 [ ] #include <fcntl.h> #define CMASK 0377 /* for making char s > 0 */ int getchar( ) { char c; /* char read */ } return(( read(0, &c, 1) > 0)? c & CMASK : EOF); UNIX

236 [ ] #include <fcntl.h> #define CMASK 0377 #define BUFSIZE 512 int getchar( ) { static char buf[bufsize]; static char *bufp = buf; static int n = 0; if( n = = 0){ n = read(0, buf, BUFSIZE); bufp = buf; } return ( (--n >= 0)? *bufp++ & CMASK : EOF); } UNIX

237 4. I/O [ ] pos n long lseek(int fd, long offset, int origin); int get(int fd, int pos, char *buf, int n) origin offset origin { SEEK_SET, lseek(fd, SEEK_CUR, pos, 0); SEEK_END offset long return(read(fd, buf, n)); lseek(fd, 0l, 2); } lseek(fd, -5l, 2); 5 lseek -1 UNIX

238 C 1983 ACM UNIX C Ken Thompson 1040 C C

239 char s[ ] = { \t, 0, \n, } ;, \n, \n, /, *, \n, (213 lines deleted) 0 }; /* The string is a * representations of the body * of this program from 0 * to the end */ main( ) { } int i; C printf( char \ts[ ] = { \n }; for(i=0; s[i]; i++) printf( \t%d\n,\n, s[i]; printf( %s, s); s C Trojan horse UNIX C Ken Thompson

240

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

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

( 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

FY.DOC

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

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

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

附錄C.doc C C C-1 C -2 C -3 C -4 C -5 / C -6 2 C/C++ C-1 FILE* fopen(const char* filename, const char* mode) filename NULL FILE* freopen(const

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

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

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

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

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

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

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

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

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 不 料 料 例 : ( 料 ) 串 度 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++ 程式設計

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

四川省普通高等学校

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

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

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

untitled

untitled 1 DBF (READDBF.C)... 1 2 (filetest.c)...2 3 (mousetes.c)...3 4 (painttes.c)...5 5 (dirtest.c)...9 6 (list.c)...9 1 dbf (readdbf.c) /* dbf */ #include int rf,k,reclen,addr,*p1; long brec,erec,i,j,recnum,*p2;

More information

C

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

More information

c_cpp

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

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

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

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

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

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

, 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

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

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

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

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

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

More information

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

华恒家庭网关方案

华恒家庭网关方案 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

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

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

More information

ebook15-C

ebook15-C C 1 1.1 l s ( 1 ) - i i 4. 14 - d $ l s -ldi /etc/. /etc/.. - i i 3077 drwxr-sr-x 7 bin 2048 Aug 5 20:12 /etc/./ 2 drwxr-xr-x 13 root 512 Aug 5 20:11 /etc/../ $ls -ldi /. /..... i 2 2 drwxr-xr-x 13 root

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

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

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

科学计算的语言-FORTRAN95

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

More information

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

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

More information

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 Word - Final Exam Review Packet.docx

Microsoft Word - Final Exam Review Packet.docx Do you know these words?... 3.1 3.5 Can you do the following?... Ask for and say the date. Use the adverbial of time correctly. Use Use to ask a tag question. Form a yes/no question with the verb / not

More information

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

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

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

1.2 关 于 二 进 制 1.2.1 什 么 是 二 进 制 我 们 日 常 所 用 的 计 数 制 是 十 进 制, 即 逢 十 进 一, 每 一 位 的 基 数 是 十 的 若 干 次 幂, 如 1980=1 10 3 +9 10 2 +8 10 1 +0 10 0 所 谓 二 进 制 与 之

1.2 关 于 二 进 制 1.2.1 什 么 是 二 进 制 我 们 日 常 所 用 的 计 数 制 是 十 进 制, 即 逢 十 进 一, 每 一 位 的 基 数 是 十 的 若 干 次 幂, 如 1980=1 10 3 +9 10 2 +8 10 1 +0 10 0 所 谓 二 进 制 与 之 C++ 程 序 设 计 课 程 简 介 课 程 沿 革 课 程 要 求 课 程 内 容 教 学 内 容 讲 课 学 时 上 机 学 时 计 算 机 基 础 知 识 4 C++ 入 门 与 基 本 数 据 类 型 4 表 达 式 和 语 句 6 4 函 数 和 程 序 结 构 8 4 数 组 和 结 构 6 4 指 针 和 引 用 8 面 向 对 象 程 序 设 计 3 类 与 构 造 函 数 8 4

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

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

(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

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

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

ebook 241-1

ebook 241-1 C 1 C C C 1.1 hello, world C hello, world #include main() printf("hello, world\n"); 2 C U N I X. c h e l l o. cc hello.c a. o u t a. out a. o u t hello, world #include main() main main

More information

Microsoft Word - PHP7Ch01.docx

Microsoft Word - PHP7Ch01.docx PHP 01 1-6 PHP PHP HTML HTML PHP CSSJavaScript PHP PHP 1-6-1 PHP HTML PHP HTML 1. Notepad++ \ch01\hello.php 01: 02: 03: 04: 05: PHP 06:

More information

Microsoft Word - 01.DOC

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

More information

bingdian001.com

bingdian001.com TSM12M TSM12 STM8L152C6, STM8L152R8 MSP430F5325 whym1987@126.com! /******************************************************************************* * : TSM12.c * : * : 2013/10/21 * : TSM12, STM8L f(sysclk)

More information

DR2010.doc

DR2010.doc DR/2010 HACH 11-8-96-2 HACH. DR/2010, / UL E79852 CSA C22.223 LR 58275 VDE GS 1015-92 FCC"A" 15 : AMADOR CORP, HACH. EN50 011/CISPR 11 "B" (EMI)/89/336/EEC/EMC: AMADOR CORP, HACH.. EN50 082-1( )/89/226/EEC

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

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

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

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

第三节 软件测试的过程与策略

第三节 软件测试的过程与策略 ...1...4...9...17...25...29...34...40...46...55...65...73 1 2 3 4 5 6 7 8 9 10 11 1 12 13 1 ABCD 2 A B C D 3 ABCD 4 A1/2 B1/3 C1/4 D2/3 5 % A20 B30 C40 D50 6 A B C D 7 A B C D / 8 A B C D 9 A B C D 10

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

How to Debug Tuxedo Server printf( Input data is: %s, inputstr); fprintf(stdout, Input data is %s, inputstr); fprintf(stderr, Input data is %s, inputstr); printf( Return data is: %s, outputstr); tpreturn(tpsuccess,

More information

文件

文件 CH10 文件 1 文件的概念 一 文件分类 二 文件的组织结构 : ASCII 码文件 ( 文本文件 ) 二进制文件 文件是二进制代码的, 则文件就是字节流 文件是 ASCII 码的, 则文件就是字符流, 也是字节流 1 如 : 对于整型变量 x, 其值为 32767 若以文本方式存放, 则共有 5 个字符, 内容为 : 00110011 00110010 00110111 00110110 00110111

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

Microsoft Word - C-pgm-ws2010.doc

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

More information

第11章 可调内核参数

第11章 可调内核参数 11 11 Unix BSD 4.4 Linux sysctl Unix Linux /proc window /proc /proc/sys /proc/sys sysctl Unix root /proc/sys/vm root /proc/sys sysctl /proc/sys struct ctl_table 18274 struct ctl_tables /proc/sys struct

More information

untitled

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

More information

Microsoft 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

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3 浙江大学 C 程序设计及实验 试题卷 2002-2003 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:30-10:30 注意 : 答题内容必须写在答题卷上, 写在本试题卷上无效 一. 单项选择题 ( 每题 1 分, 共 10 分 ) 1. 下列运算符中, 优先级最低的是 A.

More information

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

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

More information

引言

引言 BELL 18% 15% 50% 20% BELL 10% 2. 2.1. < 1> 4 TAB < 2> > (1) printf("%d %d %d", a, b, c); (2), "=" "+=" "+" "%" "&&" "&" "

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

wedding calendar

wedding calendar W TAIPEI PRESENTS YOUR WEDDING YOUR WAY W SELECTED WEDDING DAY W JANUARY FEBRUARY MARCH APRIL 4 5 6 4 5 6 7 7 8 9 10 11 12 13 8 9 10 11 12 13 14 14 15 16 17 18 19 20 15 16 17 18 19 20 21 21 22 23 24 25

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

Microsoft Word - 实用案例.doc

Microsoft Word - 实用案例.doc 计 算 机 系 统 应 用 2009 年 第 12 期 嵌 入 式 Linux 下 温 湿 度 传 感 器 的 设 计 与 实 现 1 Design and Implementation of Temperature and Humidity Sensor Based on Embedded Linux 陈 博 刘 锦 高 ( 华 东 师 范 大 学 电 子 科 学 技 术 系 上 海 200241)

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

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

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

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

Microsoft PowerPoint - 07_IO.ppt

Microsoft PowerPoint - 07_IO.ppt I/O 设备 C 程序设计语言 第 7 章 I/O 孙志岗 sun@hit.edu.cn http://sunner.cn 输入设备 键盘 鼠标 软盘 硬盘 光驱 ( 以文件的形式 ) 串行口 并行口 USB 接口 IEEE1394 口 网络端口 扫描仪 视频采集卡 电视卡 游戏杆 话筒 输出设备 显示器 打印机 软盘 硬盘 CD-RW/DVD RW/DVD-RW( ( 以文件的形式 ) 串行口 并行口

More information

TX-NR3030_BAS_Cs_ indd

TX-NR3030_BAS_Cs_ indd TX-NR3030 http://www.onkyo.com/manual/txnr3030/adv/cs.html Cs 1 2 3 Speaker Cable 2 HDMI OUT HDMI IN HDMI OUT HDMI OUT HDMI OUT HDMI OUT 1 DIGITAL OPTICAL OUT AUDIO OUT TV 3 1 5 4 6 1 2 3 3 2 2 4 3 2 5

More information

ebook39-5

ebook39-5 5 3 last-in-first-out, LIFO 3-1 L i n e a r L i s t 3-8 C h a i n 3 3. 8. 3 C + + 5.1 [ ] s t a c k t o p b o t t o m 5-1a 5-1a E D 5-1b 5-1b E E 5-1a 5-1b 5-1c E t o p D t o p D C C B B B t o p A b o

More information

Sea of Japan Hokkaido Okhotsk Sea Study area Number of fish released (thousand) 120,000 100,000 80,000 60,000 40,000 20,000 0 1991 1993 1995 1997 1999 2001 Year Fish released in rivers Fish released from

More information

Viu_Cover

Viu_Cover November 2016 Program Highlights G1 1O1O 1O G1 V Henry Chan show (Hidy) Charlene Houghton MMA G-1 G-1 # 11 7-8 22:00-23:00 260 * $380,000 * $185,000 ViuTV (Advance Commitment Scheme) # 10 22-11 13 22:30-23:30

More information

Ps22Pdf

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

More information

download.kaoyan.com_2006ÄêÌì½ò¹¤Òµ´óѧ¸ß¼¶ÓïÑÔ³ÌÐòÉè¼Æ£¨409£©¿¼ÑÐÊÔÌâ

download.kaoyan.com_2006ÄêÌì½ò¹¤Òµ´óѧ¸ß¼¶ÓïÑÔ³ÌÐòÉè¼Æ£¨409£©¿¼ÑÐÊÔÌâ 考生注意 : 本试卷共七大题, 满分 150 分 考试时间为 3 小时 ; 所有答案均写在答题纸上 ( 注明题号 ), 在此答题一律无效无效 一 选择题 ( 本题共 20 小题, 每小题 2 分, 满分 40 分 ) 1 char ch 1 2 A 0

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

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

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

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション Perl CGI 1 Perl CGI 2 Perl CGI 3 Perl CGI 4 1. 2. 1. #!/usr/local/bin/perl 2. print "Content-type: text/html n n"; 3. print " n"; 4. print " n"; 3. 4.

More information

Progperl.PDF

Progperl.PDF print "Howdy, world!\n"; 1 2 / / 3 4 / $phrase = " Howdy, world!\n"; print $phrase ; # # / 5 6 / $answer = 42; $pi = 3.14159265; $avocados = 6.02e23; $pet = "Camel"; $sign = "I love my $pet"; $cost = 'It

More information

Microsoft Word - CIN-DLL.doc

Microsoft Word - CIN-DLL.doc 6.3. 调 用 动 态 链 接 库 (DLL) 相 对 于 CIN 来 讲,NI 更 推 荐 用 户 使 用 DLL 来 共 享 基 于 文 本 编 程 语 言 开 发 的 代 码 除 了 共 享 或 重 复 利 用 代 码, 开 发 人 员 还 能 利 用 DLL 封 装 软 件 的 功 能 模 块, 以 便 这 些 模 块 能 被 不 同 开 发 工 具 利 用 在 LabVIEW 中 使 用

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

Bus Hound 5

Bus Hound 5 Bus Hound 5.0 ( 1.0) 21IC 2007 7 BusHound perisoft PC hound Bus Hound 6.0 5.0 5.0 Bus Hound, IDE SCSI USB 1394 DVD Windows9X,WindowsMe,NT4.0,2000,2003,XP XP IRP Html ZIP SCSI sense USB Bus Hound 1 Bus

More information

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

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