C/C++ 语言 - 循环

Size: px
Start display at page:

Download "C/C++ 语言 - 循环"

Transcription

1 C/C++

2 Table of contents while for (do while) (nested loop)

3

4 // summing.c: # include <stdio.h> int main ( void ) { long num ; long sum = 0L; int status ; printf (" Enter an integer to be summed "); printf ("(q to quit ): "); status = scanf ("%ld", & num ); while ( status == 1) { sum = sum + num ; printf (" Enter next integer (q to quit ): "); status = scanf ("%ld", & num ); } printf (" Those integers sum to %ld.\n", sum ); return 0; } 2

5 Enter an integer to be summed ( q to quit ): 22 Enter next integer ( q to quit ): 33 Enter next integer ( q to quit ): 44 Enter next integer ( q to quit ): q Those integers sum to 99. 3

6 while

7 while while ( condition ) statement while ( condition ) { statements } 4

8 while no go to next statement condition yes { } statements; 5

9 while while while 6

10 while while index = 1; while ( index < 5) { printf (" Good morning!\n"); } 7

11 while while index = 1; while ( index < 5) { printf (" Good morning!\n"); } index 7

12 while while index = 1; while (-- index < 5) { printf (" Good morning!\n"); } 8

13 while while index = 1; while (-- index < 5) { printf (" Good morning!\n"); } index 8

14 while while index = 1; while (++ index < 5) { printf (" Good morning!\n"); } 9

15 while while index = 1; while (++ index < 5) { printf (" Good morning!\n"); } 9

16 while 10

17 while 1 // when.c: 2 # include <stdio.h> 3 int main ( void ) 4 { 5 int n = 5; 6 while (n < 7) { 7 printf ("n = %d\n", n); 8 n ++; 9 printf (" Now n = %d\n", n); 10 } 11 return 0; 12 } n = 5 Now n = 6 n = 6 Now n = 7 11

18 while while while 12

19 while index = 10; while ( index ++ < 5) printf (" Have a fair day or better.\n"); 13

20 while index = 10; while ( index ++ < 5) printf (" Have a fair day or better.\n"); index = 3; 13

21 while while 14

22 while 1 // while1.c: 2 # include <stdio.h> 3 int main ( void ) 4 { 5 int n = 0; 6 while ( n < 3) 7 printf ("n = %d\n", n); 8 n ++; 9 printf (" That s all this " 10 " program does.\n"); 11 return 0; 12 } 15

23 while 1 // while1.c: 2 # include <stdio.h> 3 int main ( void ) 4 { 5 int n = 0; 6 while ( n < 3) 7 printf ("n = %d\n", n); 8 n ++; 9 printf (" That s all this " 10 " program does.\n"); 11 return 0; 12 } n = 0 n = 0 n = 0 n =

24 while while while 16

25 while 1 // while2.c: 2 # include <stdio.h> 3 int main ( void ) 4 { 5 int n = 0; 6 while (n++ < 3); 7 printf ("n = %d\n", n); 8 printf (" That s all this program does.\n"); 9 return 0; 10 } 17

26 while 1 // while2.c: 2 # include <stdio.h> 3 int main ( void ) 4 { 5 int n = 0; 6 while (n++ < 3); 7 printf ("n = %d\n", n); 8 printf (" That s all this program does.\n"); 9 return 0; 10 } n = 4 That s all this program does. 17

27 while C (null statement) 18

28 while while 19

29 while while while ( scanf ("%d",& num ) ==1) ; 19

30 while while while ( scanf ("%d",& num ) ==1) ; while 19

31

32 1: < <= > >= ==!= 20

33 while C 21

34 while ( number < 6) { printf (" Your number is too small.\n"); scanf ("%d", & number ); } 22

35 while ( number < 6) { printf (" Your number is too small.\n"); scanf ("%d", & number ); } while (ch!= * ) { count ++; scanf ("%c", &ch); } 22

36 while ( number < 6) { printf (" Your number is too small.\n"); scanf ("%d", & number ); } while (ch!= * ) { count ++; scanf ("%c", &ch); } while ( scanf ("%f", & num ) == 1) sum = sum + num ; 22

37 23

38 < > 3 1 == /

39 < > 3 1 == / math.h fabs() 23

40 // cmpflt.c: # include <stdio.h> # include <math.h> int main ( void ) { const double PI = ; double response ; printf (" What is the value of pi?\n"); scanf ("%lf", & response ); while ( fabs ( response -PI) >0.0001) { printf (" Try again!\n"); scanf ("%lf", & response ); } printf (" Close enough!\n"); return 0; } 24

41 What is the value of pi? 3.14 Try again! Close enough! 25

42 // t_and_f.c # include <stdio.h> int main ( void ) { int true_ val, false_ val ; true_ val = (10 > 2); false_ val = (10 == 2); printf (" true = %d; false = %d\n", true_val, false_val ); return 0; } 26

43 // t_and_f.c # include <stdio.h> int main ( void ) { int true_ val, false_ val ; true_ val = (10 > 2); false_ val = (10 == 2); printf (" true = %d; false = %d\n", true_val, false_val ); return 0; } true = 1; false = 0 26

44 C

45 C 1 0 while (1) {... } 27

46 1 0 while 28

47 i // truth.c # include <stdio.h> int main ( void ) { int n = 3; while (n) printf ("%2d is true \n", n - -); printf ("%2d is false \n", n); n = -3; while (n) printf ("%2d is true \n", n ++) ; printf ("%2d is false \n", n); return 0; } 29

48 3 is true 2 is true 1 is true 0 is false -3 is true -2 is true -1 is true 0 is false 30

49 C/C

50 C/C++ 0 while (n!= 0) {... } while (n) {... } 31

51 // trouble.c: # include <stdio.h> int main ( void ) { long num ; long sum = 0L; int status ; printf (" Enter an integer to be summed "); printf ("(q to quit ): \n"); status = scanf ("%ld", & num ); while ( status = 1) { sum = sum + num ; printf (" Enter next integer (q to quit ):\n"); status = scanf ("%ld", & num ); } printf (" Those integers sum to %ld.\n", sum ); return 0; } 32

52 Enter an integer to be summed ( q to quit ): 1 Enter next integer ( q to quit ): 2 Enter next integer ( q to quit ): 3 Enter next integer ( q to quit ): q Enter next integer ( q to quit ): Enter next integer ( q to quit ): Enter next integer ( q to quit ):... 33

53 while status=1 status==1 status=1 1 while ( status = 1) while (1) 34

54 q scanf() scanf() q q q scanf() 35

55 == = = == i = 5 // i 5 i == 5 // i 5 == 5 = i // 5 == i // i 5 36

56 1 0 while if 37

57 _Bool / C int C99 _Bool C 38

58 _Bool // boolean.c: # include <stdio.h> int main ( void ) { long num ; long sum = 0L; _Bool input_ is_ good ; printf (" Enter an integer to be summed "); printf (" (q to quit ):\n"); input_is_good = ( scanf ("%ld", & num ) == 1); while ( input_ is_ good ) { sum = sum + num ; printf (" Enter next integer (q to quit ):\n"); input_is_good = ( scanf ("%ld", & num ) == 1); } printf (" Those integers sum to %ld.\n", sum ); return 0; } 39

59 _Bool input_is_good = ( scanf ("%ld", & num ) == 1); == == = while ( input_is_good ) 40

60 _Bool C99 stdbool.h bool _Bool true false

61 _Bool // boolean1.c: # include <stdio.h> # include < stdbool.h> int main ( void ) { long num ; long sum = 0L; bool input_ is_ good ; printf (" Enter an integer to be summed "); printf (" (q to quit ):\n"); input_is_good = ( scanf ("%ld", & num ) == true ); while ( input_ is_ good ) { sum = sum + num ; printf (" Enter next integer (q to quit ):\n"); input_is_good = ( scanf ("%ld", & num ) == true ); } printf (" Those integers sum to %ld.\n", sum ); return 0; } 42

62 + - x > y+2 x > (y +2) x = y > 2 x = ( y > 2) x_ bigger = x > y x_ bigger = ( x > y) 43

63 2: < <= > >= ==!= 44

64 c!= a == b ( c!= a) == b 45

65 () sizeof (type) * / % + - < <= > >= ==!= = 46

66

67 47

68 // sweetie1.c: # include <stdio.h> int main ( void ) { const int NUMBER = 2; int count = 1; while ( count <= NUMBER ) { printf (" Hello world!\n"); count ++; } return 0; } 48

69 49

70 while ( count <= NUMBER ){... count ++; } = while ( count ++ <= NUMBER ){... } 50

71 for

72 for for ( initialization ; condition ; increment ) { statements } for ( initialization ; condition ; increment ) statement for 51

73 for // sweetie2.c: # include <stdio.h> int main ( void ) { const int NUMBER = 4; int count ; for ( count = 0; count < NUMBER ; count ++) printf (" Hello world!\n"); } return 0; 52

74 for Hello world! Hello world! Hello world! Hello world! 53

75 for for 1. for

76 for # include <stdio.h> int main ( void ) { int num ; printf ("%3s %8s\n", "n", "n cubed "); for ( num = 1; num <= 4; num ++) printf ("%3d %8d\n", num, num * num * num ); return 0; } 55

77 for n n cubed

78 for for 1 // for_down.c: # include <stdio.h> int main ( void ) { int secs ; for ( secs = 4; secs > 0; secs - -) printf ("%d seconds!\n", secs ); printf (" Ignition!\n"); return 0; } 57

79 for for 4 seconds! 3 seconds! 2 seconds! 1 seconds! Ignition! 58

80 for for // for_13s.c: # include <stdio.h> int main ( void ) { int n; for ( n = 2; n < 60; n = n +13) printf ("%d\n", n); return 0; } 59

81 for for

82 for for 3 // for_char.c: # include <stdio.h> int main ( void ) { char ch; for (ch = a ; ch <= z ; ch ++) printf (" The ASCII value of %c is %d\n", ch, ch); return 0; } 61

83 for for The ASCII value of a is 97 The ASCII value of b is The ASCII value of y is 121 The ASCII value of z is

84 for for 4 // for_cube1.c: # include <stdio.h> int main ( void ) { int num ; printf ("%3s %8s\n", "n", "n cubed "); for ( num = 1; num * num * num <= 64; num ++) printf ("%3d %8d\n", num, num * num * num ); return 0; } 63

85 for for n n cubed

86 for for 5 // for_geo.c: # include <stdio.h> int main ( void ) { double debt ; for ( debt = ; debt <= 140; debt = debt * 1. 1) printf (" Your debt is now $ %.2 f\n", debt ); return 0; } 65

87 for for Your debt is now $ Your debt is now $ Your debt is now $ Your debt is now $

88 for for 6 // for_wild.c: # include <stdio.h> int main ( void ) { int x; int y = 55; for ( x = 1; y <= 75; y = (++ x * 5) + 50) printf (" %10 d %10 d\n", x, y); return 0; } 67

89 for for

90 for for 7 69

91 for for // for_none.c: # include <stdio.h> int main ( void ) { int ans, n; ans = 2; for ( n = 3; ans <= 25; ) ans = ans * n; printf ("n = %d; ans = %d.\n", n, ans ); return 0; } 70

92 for for n = 3; ans =

93 for for for ( ; ; ) printf ("I want som action \n"); 72

94 for for 8 printf 73

95 for for // for_show.c: # include <stdio.h> int main ( void ) { int num ; for ( printf (" Keep entering numbers!\n"); num!=6; ) scanf ("%d", & num ); printf (" That s the one I want!\n"); return 0; } 74

96 for for Keep entering numbers! 2 6 That s the one I want! 75

97 for for 9 for ( n = 1; n < 10000; n = n + delta ) delta if delta 76

98

99 += -= *= /= %= 77

100 num += 20 num -= 20 num /= 20 num *= 20 num %= 20 num = num + 20 num = num - 20 num = num / 20 num = num * 20 num = num % 20 78

101 num += 20 num -= 20 num /= 20 num *= 20 num %= 20 num = num + 20 num = num - 20 num = num / 20 num = num * 20 num = num % 20 x *= 3 * y + 12 x = x * (3 * y + 12) 78

102 = xxxxyyyyzzzz *= 3 xxxxyyyyzzzz = xxxxyyyyzzzz * 3 79

103

104 for for 80

105

106 1 // postage.c: 2 # include <stdio.h> 3 int main ( void ) 4 { 5 const int FIRST_ OZ = 37, NEXT_ OZ = 23; 6 int ounces, cost ; 7 for ( ounces = 1, cost = FIRST_ OZ ; 8 ounces <= 16; 9 ounces ++, cost += NEXT_ OZ ) 10 printf ("%2d $ %4.2 f\n", ounces, cost /100.0) ; 11 return 0; 12 } 82

107 1 $ $ $

108 ounces = 1, cost = FIRST_OZ; no ounces <= 16 ounces++, cost += NEXT_OZ yes printf("..."); 84

109 for for 85

110 ounces ++, cost = ounces * FIRST_ OZ 86

111 x = (y = 3, (z = ++y + 2) + 5); (1) y = 3; (2) y = y + 1 = 4; (3) z = ( y + 2) = (4 + 2) = 6; (4) x = z + 5 = = 11; 87

112 houseprice = 249, 500; houseprice = 249; 500; 88

113 houseprice = 249, 500; houseprice = 249; 500; C houseprice = houseprice

114 houseprice = ( 249, 500) ; 89

115 houseprice = ( 249, 500) ; 500 houseprice 89

116 int m, n; printf ("%d %d\n", m, n); 90

117 int m, n; printf ("%d %d\n", m, n); 90

118 S =

119 // zeno.c: # include <stdio.h> int main ( void ) { int count, limit ; double sum, x; printf (" Enter the number of terms : "); scanf ("%d", & limit ); for ( sum = 0., x = 1, count = 1; count <= limit ; count ++, x *= 2.) { sum += 1.0/ x; printf (" sum = %f when terms = %d.\n", sum, count ); } return 0; } 92

120 Enter the number of terms you want : 10 sum = when terms = 1. sum = when terms = 2. sum = when terms = 3. sum = when terms = 4. sum = when terms = 5. sum = when terms = 6. sum = when terms = 7. sum = when terms = 8. sum = when terms = 9. sum = when terms =

121 (do while)

122 (do while) while for do while 94

123 (do while) // do_while.c: # include <stdio.h> int main ( void ) { const int SECRET_ CODE = 13; int code_ entered ; do { printf ("To withdraw money from ATM. \n"); printf (" Enter the secret code number : "); scanf ("%d", & code_entered ); } while ( code_ entered!= SECRET_ CODE ); printf (" Congratulations! You are permitted!\ n" ); return 0; } 95

124 (do while) To withdraw money from ATM. Please enter the secret code number : 11 To withdraw money from ATM. Please enter the secret code number : 12 To withdraw money from ATM. Please enter the secret code number : 13 Congratulations! You are permitted! 96

125 (do while) i while // entry.c: # include <stdio.h> int main ( void ) { const int SECRET_ CODE = 13; int code_ entered ; printf ("To withdraw money from ATM. \n"); printf (" Enter the secret code number : "); scanf ("%d", & code_entered ); while ( code_ entered!= SECRET_ CODE ) { printf ("To withdraw money from ATM. \n"); printf (" Enter the secret code number : "); scanf ("%d", & code_entered ); 97

126 (do while) ii } } printf (" Congratulations! You are permitted!\ n" ); return 0; 98

127 (do while) do printf("ba la ba la!"); while no go to next statement count++ <= limit; yes 99

128 (do while) do { statements } while ( condition ); do statement while ( condition ); 100

129 (do while) do while do while 101

130

131 102

132 for while for (; condition ; ) while ( condition ) 103

133 while for initialization ; while ( condition ) { body ; update ; } for ( initialization ; condition ; update ){ body ; } 104

134 for while while while ( scanf ("%ld", & num ) == 1){... } for for ( count = 1; count <= 100; count ++) {... } 105

135 (nested loop)

136 (nested loop) 106

137 (nested loop) // rows1.c: # include <stdio.h> # define ROWS 6 # define CHARS 10 int main ( void ) { int row ; char ch; for ( row = 0; row < ROWS ; row ++) { for (ch = A ; ch < ( A + CHARS ); ch ++) printf ("%c ", ch); printf ("\n"); } return 0; } 107

138 (nested loop) A B C D E F G H I J A B C D E F G H I J A B C D E F G H I J A B C D E F G H I J A B C D E F G H I J A B C D E F G H I J 108

139 (nested loop) // row2.c: # include <stdio.h> # define ROWS 6 # define CHARS 6 int main ( void ) { int row ; char ch; for ( row = 0; row < ROWS ; row ++) { for (ch = A + row ; ch < ( A + CHARS ); ch ++) printf ("%c ", ch); printf ("\n"); } return 0; } 109

140 (nested loop) A B C D E F B C D E F C D E F D E F E F F 110

141

142 111

143 float debts [20]; debts 20 float debts[0] debts[1]... float debts [3] = 2.; debts [7] = 1.2 e +10; 112

144 scanf ("%d", & debts [4]) ; // 5 113

145 C debts [20] = 11.0; // debts [31] = 22.22; // 114

146 int num [10]; // 10 char ch [20]; // 20 double a [40]; // 40 double 115

147 (subscript) (index) (offset) 0 116

148 for 5 117

149 i // scores.c: # include <stdio.h> # define DAYS 5 # define PAR int main ( void ) { int index, steps [ DAYS ]; int sum = 0; float average ; printf (" Enter steps of %d days :\n", DAYS ); for ( index = 0; index < DAYS ; index ++) scanf ("%d", & steps [ index ]); printf (" The steps read in are as follows :\ n"); for ( index = 0; index < DAYS ; index ++) printf ("%7d", steps [ index ]); printf ("\n"); 118

150 ii } for ( index = 0; index < DAYS ; index ++) sum += steps [ index ]; average = ( float ) sum / DAYS ; printf (" Sum of steps = %d, average = %.2 f\ n", sum, average ); printf (" That s a handicap of %.0 f.\n", average - PAR ); return 0; 119

151 Enter steps of 5 days : The steps read in are as follows : Sum of steps = 54151, average = That s a handicap of

152

153 n p 121

154 n p math.h pow 121

155 pow 1 // pow.c: 2 # include <stdio.h> 3 # include <math.h> 4 int main ( void ) 5 { 6 printf (" 2^3 = %f\n", pow (2.0,3.0) ); 7 printf (" sqrt 2 = %f\n", pow (2.0,0.5) ); 8 printf (" 3^(1/4) = %f\n", pow (3.0,0.25) ); 9 return 0; 10 } 122

156 pow 2^3 = sqrt 2 = ^( 1/ 4) =

157 1 double power ( double n, int p) 2 { 3 double pow = 1; 4 int i; 5 for (i = 1; i <= p; i ++) 6 pow *= n; 7 return pow ; 8 } 124

158 return 125

159 return return 2 * x + b; 126

160 b = power (1.2, 3); b = power (1.2, 3); printf ("%f", power (1.2, 3)); 127

161 power i // power.c: # include <stdio.h> double power ( double n, int p); int main ( void ) { double x, xpow ; int exp ; printf (" Enter a number and the positive integer power \n"); printf (" Enter q to quit.\n"); while ( scanf ("%lf%d", &x, & exp ) == 2) { xpow = power (x, exp ); printf (" %.3 g to the power %d is %.5 g\n", x, exp, xpow ); printf (" Enter next pair of numbers or q to quit.\ n "); 128

162 power ii } printf (" Hope you enjoyed this power trip -- bye!\ n") ; return 0; } double power ( double n, int p) { double pow = 1; int i; for ( i = 1; i <= p; i ++) pow *= n; return pow ; } 129

163 power Enter a number and the positive integer power to which the number will be raised. Enter qto quit to the power 12 is Enter next pair of numbers or q to quit to the power 16 is Enter next pair of numbers or q to quit. q 130

164

165

166 // ex01.c # include < stdio.h> # define N 26 int main ( void ) { int i; char alpha [N]; for (i = 0; i < N; i ++) { alpha [i] = a +i; putchar ( alpha [i]); } putchar ( \n ); return 0; } 132

167 $ $$ $$$ $$$$ $$$$$ 133

168 // ex02.c: # include <stdio.h> # define SYMBOL $ # define ROW 5 int main ( void ) { int i, j; for (i = 0; i < ROW ; i ++) { for (j = 0; j <= i; j ++) putchar ( SYMBOL ); putchar ( \n ); } return 0; } 134

169 3 F FE FED FEDC FEDCB FEDCBA 135

170 // ex03.c: # include <stdio.h> # define ROW 6 int main ( void ) { int i, j; for (i = 0; i < ROW ; i ++) { for (j = 0; j <= i; j ++) putchar ( F -j); putchar ( \n ); } return 0; } 136

171 4 A ABA ABCBA ABCDCBA ABCDEDCBA 137

172 // ex04.c: # include < stdio.h> # define ROW 5 int main ( void ) { int i, j; for (i = 0; i < ROW ; i ++) { for (j = ROW -1 -i; j >= 0; j - -) putchar ( ); for (j = 0; j <= i; j ++) putchar ( A +j); for (j = 0; j < i; j ++) putchar ( A +i -1 -j); putchar ( \n ); } return 0; 138

173 } 139

174 5 for 140

175 // ex05.c: # include <stdio.h> int main ( void ) { int i, low, high ; printf (" Enter low and high limit : "); scanf ("%d %d", &low, & high ); printf ("%4s %4s %4s\n", "n", "n^2", "n^3"); for ( i = low ; i <= high ; i ++) printf ("%4d %4d %4d\n", i, i*i, i*i*i); return 0; } 141

176 6 142

177 // ex06.c: # include < stdio.h> # include < string.h> int main ( void ) { int i; char word [20]; puts (" Enter a word : "); scanf ("%s", word ); for (i = strlen ( word ) -1; i >= 0; i - -) putchar ( word [i]); putchar ( \n ); return 0; } 143

178 7 144

179 // ex07.c # include < stdio.h> int main ( void ) { float a, b; puts (" Enter the first pair of float numbers : " ); while ( scanf ("%f %f", &a, &b) == 2) { printf (" %8.3 f %8.3 f\n", a-b, a*b); puts (" Enter the next pair of float number : " ); } puts (" Done!"); return 0; } 145

180 8 146

181 9 Enter lower and upper integer limit : 5 9 The sum of the squares from 25 to 81 is 255 Enter lower and upper integer limit : 3 25 The sum of the squares from 9 to 625 is 5520 Enter lower and upper integer limit : 5 5 Done 147

182 // ex09.c # include <stdio.h> int main ( void ) { int i, low, high ; int sum = 0; printf (" Enter lower and higher limit : "); while ( scanf ("%d %d", &low, & high ) == 2 && ( low <= high )) { for ( i = low ; i <= high ; i ++) sum += i* i; printf (" The sum of the squares from % d to % d is % d \n", low, high, sum ); } puts (" Done "); return 0; } 148

183

184 // ex10.c # include < stdio.h> # define N 8 int main ( void ) { int arr [N]; int i; puts (" Enter 8 integers : "); for (i = 0; i < N; i ++) scanf ("%d", & arr [i]); for (i = N -1; i >= 0; i - -) printf ("%4d ", arr [i]); putchar ( \n ); return 0; } 150

185 n ( 1)n+1 1 n + n n = 20,100,

186 // ex11.c # include < stdio.h> int main ( void ) { int i, n; int symbol = -1; double s1 = 0.0, s2 = 0.0; puts (" Enter the value of n:"); scanf ("%d", &n); for (i = 1; i <= n; i ++) { s1 += 1.0 / i; symbol *= -1; s2 += ( float ) symbol / i; } printf ("s1 = %.5 f when n = %d\n", s1, n); printf ("s2 = %.5 f when n = %d\n", s2, n); return 0; } 152

187 12 8 int 2 8 for do while 153

188 // ex12.c # include < stdio.h> # define N 8 int main ( void ) { int i; int arr [N]; for (i = 1, arr [0] = 2; i < N; i ++) arr [i] = arr [i -1]*2; i = 0; do { printf ("%4d\n", arr [i ++]) ; } while (i<n); return 0; } 154

189 13 8 double 8 i i 155

190 // ex13.c # include < stdio.h> # define N 4 int main ( void ) { int i; double sum = 0. 0; double arr1 [N], arr2 [N]; printf (" Enter %d double elements : ", N); for (i = 0; i < N; i ++) { scanf ("%lf", & arr1 [i]); sum += arr1 [i]; arr2 [i] = sum ; } for (i = 0; i < N; i ++) { printf (" %8.3 f", arr1 [i]); } 156

191 } putchar ( \n ); for (i = 0; i < N; i ++) { printf (" %8.3 f", arr2 [i]); } putchar ( \n ); return 0; 157

192 14 158

193 // ex14.c # include < stdio.h> # include < string.h> # define N 255 int main ( void ) { char line [N]; char ch; int i = 0; puts (" Enter a line text : "); while (( ch = getchar ())!= \n ) line [i ++] = ch; line [i]= \0 ; for (i = strlen ( line ) -1; i >= 0; i - -) putchar ( line [i]); putchar ( \n ); return 0; } 159

194 15 10% %

195 // ex15.c # include < stdio.h> # define INVEST 1000 # define RATE1 0.1 # define RATE int main ( void ) { int year ; double wang, li; wang = li = INVEST ; for ( year = 1; li <= wang ; year ++) { wang += INVEST * RATE1 ; li *= (1+ RATE2 ); printf ("%4d %8.3 f %8.3 f\n", year, wang, li); } return 0; } 161

196 %

197 // ex16.c # include < stdio.h> # define LOTTERY # define RATE int main ( void ) { int year ; double wang = LOTTERY ; for ( year = 1; wang >= 0. 0; year ++) { wang *= (1+ RATE ); wang -= 10. 0; printf ("%4d %8.3 f\n", year, wang ); } return 0; } 163

C

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

More information

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

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 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++ - 函数

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

More information

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

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

More information

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

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

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

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

More information

新版 明解C言語入門編

新版 明解C言語入門編 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

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

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 1

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

More information

untitled

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

More information

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

新・明解C言語入門編『索引』 !... 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言語 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

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

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

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 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

CC213

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

More information

C C

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

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

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

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

Microsoft Word - 第3章.doc

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

More information

2013 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

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

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

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

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

CHAPTER VC#

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

More information

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

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 5 Spring 2005 March 25, 2005 Topics Review Loop Statements For-Loop Condition-Loop Arrays: Part I Function Definition: Part I 1 Review of Loop Statements (Repetition

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

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++ 程式設計

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

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

FY.DOC

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

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

新・解きながら学ぶJava

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

More information

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

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc 2 5 8 11 0 1. 13 2. 15 3. 18 1 1. 22 2. 25 3. 27 2 1. 35 2. 38 3. 41 4. 43 5. 48 6. 50 3 1. 56 2. 59 3. 63 4. 65 5. 69 13 22 35 56 6. 74 7. 82 8. 84 9. 87 10. 97 11. 102 12. 107 13. 111 4 114 1. 114 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

untitled

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

More information

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

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

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

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

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

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

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

高中英文科教師甄試心得

高中英文科教師甄試心得 高 中 英 文 科 教 師 甄 試 心 得 英 語 學 系 碩 士 班 林 俊 呈 高 雄 市 立 高 雄 高 級 中 學 今 年 第 一 次 參 加 教 師 甄 試, 能 夠 在 尚 未 服 兵 役 前 便 考 上 高 雄 市 立 高 雄 高 級 中 學 專 任 教 師, 自 己 覺 得 很 意 外, 也 很 幸 運 考 上 後 不 久 在 與 雄 中 校 長 的 會 談 中, 校 長 的 一 句

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

四川省普通高等学校

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

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

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

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

More information

<5B BECBB0EDB8AEC1F25D312D34B0AD5FC3E2BCAEBCF6BEF7C0DAB7E F31702E504446>

<5B BECBB0EDB8AEC1F25D312D34B0AD5FC3E2BCAEBCF6BEF7C0DAB7E F31702E504446> : 2 = 3 4? 0 an ordered set of unambiguous, executable steps that produces a result and terminates in a finite time (computational theory) ( ) 5 6 (C-) int min, max; float degree, b; char ch, token; /,,,

More information

Microsoft Word - 圣经释经学

Microsoft Word - 圣经释经学 圣 经 释 经 学 一 个 信 实 地 解 释 神 话 语 的 任 务 编 辑 者 : 罗 大 卫 ~ 0 ~ 内 容 目 录 第 一 天 第 一 课 简 介 第 二 课 设 置 基 础 第 三 课 解 释 的 方 法 第 二 天 第 四 课 圣 经 的 权 威 第 五 课 圣 经 有 一 个 故 事 主 线 第 六 课 被 传 讲 的 神 话 语 的 力 量 第 七 课 释 经 的 过 程 第 三

More information

Gerotor Motors Series Dimensions A,B C T L L G1/2 M G1/ A 4 C H4 E

Gerotor Motors Series Dimensions A,B C T L L G1/2 M G1/ A 4 C H4 E Gerotor Motors Series Size CC-A Flange Options-B Shaft Options-C Ports Features 0 0 5 5 1 0 1 0 3 3 0 0 SAE A 2 Bolt - (2) 4 Bolt Magneto (4) 4 Bolt Square (H4) 1.0" Keyed (C) 25mm Keyed (A) 1.0' 6T Spline

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

PowerPoint Presentation

PowerPoint Presentation Visual Basic 2005 學 習 範 本 第 7 章 陣 列 的 活 用 7-1 陣 列 當 我 們 需 要 處 理 資 料 時, 都 使 用 變 數 來 存 放 資 料 因 為 一 個 變 數 只 能 代 表 一 個 資 料, 若 需 要 處 理 100 位 同 學 的 成 績 時, 便 要 使 用 100 個 不 同 的 變 數 名 稱, 這 不 但 會 增 加 變 數 名 稱 命 名

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

Microsoft Word - 095_2015.09.26 什麼最快樂 (白話與經文加註)-ok .doc

Microsoft Word - 095_2015.09.26  什麼最快樂 (白話與經文加註)-ok .doc 釋 厚 觀 ( 福 嚴 推 廣 教 育 班,2015.9.26) 各 位 法 師 各 位 居 士, 大 家 好! 今 天 跟 大 家 分 享 一 則 佛 典 故 事, 這 故 事 出 自 法 句 譬 喻 經, 在 大 正 藏 第 4 冊 595 頁 中 欄 到 596 頁 上 欄 過 去, 佛 在 舍 衛 國 祇 園 精 舍 時, 有 四 位 新 學 比 丘 一 起 來 到 㮈 樹 下 坐 禪 修

More information

PIC_SERVER (11) SMTP ( ) ( ) PIC_SERVER (10) SMTP PIC_SERVER (event driven) PIC_SERVER SMTP 1. E-

PIC_SERVER (11) SMTP  ( ) ( ) PIC_SERVER (10) SMTP  PIC_SERVER (event driven)  PIC_SERVER SMTP  1.  E- (2005-02-01) (2005-04-28) PIC_SERVER (10) SMTP E-mail PIC_SERVER (event driven) E-mail PIC_SERVER SMTP E-mail 1. E-mail E-mail 1 (1) (2) (3) (4) 1 1. 2 E-mail A E-mail B E-mail SMTP(Simple Mail Transfer

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

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

家长讲师团案例之一

家长讲师团案例之一 书 香 的 气 息 哲 思 的 气 韵 高 远 的 气 质 主 编 : 费 建 华 题 字 : 朱 永 新 2011-2012 学 年 度 第 一 学 期 第 5 期 ( 总 181 期 ) 教 师 论 文 简 论 中 学 历 史 教 学 中 的 学 生 自 学 历 史 组 周 昆 内 容 摘 要 : 众 所 周 知, 论 从 史 出 只 有 掌 握 了 一 定 的 历 史 信 息, 才 能 分 析

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

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

CHAPTER 1

CHAPTER 1 CHAPTER 1 1-1 System Development Life Cycle; SDLC SDLC Waterfall Model Shelly 1995 1. Preliminary Investigation 2. System Analysis 3. System Design 4. System Development 5. System Implementation and Evaluation

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

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

攝 心 為 戒, 因 戒 而 生 定, 由 定 而 生 慧

攝 心 為 戒, 因 戒 而 生 定, 由 定 而 生 慧 攝 心 為 戒, 因 戒 而 生 定, 由 定 而 生 慧 序 言 談 佛 教 戒 律 論 修 行 念 佛 多 如 牛 毛 往 生 極 樂 少 如 牛 角 戒 律 者, 如 同 國 之 法 律, 民 不 守 之, 則 社 稷 亂 矣, 而 修 行 者, 不 守 戒, 則 道 不 成, 宗 教 崩 廢 不 堪 矣 國 法 乃 依 行 而 論 處, 戒 律 者, 乃 心 行 皆 論, 較 之 嚴 謹 今

More information

!!! ! " # $% $& $#!!!!&!(!# %$ %) $ !"!#!$ %& % %% %( "& "% "$ #) #% (& (! (# (* $! !" #$ #% & & & " & # &&& &&( &&$ &&% &&# &)& &)* * !"#!$%!$&!!! $! %!()!(!(%!(&!#!##!#&!%"!%#!%&!*$ !"#!$%!$&!$ (%%

More information

untitled

untitled () 1 2 (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) 3 (1) (2) (3) (1) (2) (3) 4 A. 8 9 9 10 12 14 14 15 B. 17 : 18 18 19 22 23 5 26 31 61 : - 78 78 81 : 86 88-92 94 99 106 125 6 : 150 150 150 C. 165 :? 166

More information

Lorem ipsum dolor sit amet, consectetuer adipiscing elit

Lorem ipsum dolor sit amet, consectetuer adipiscing elit English for Study in Australia 留 学 澳 洲 英 语 讲 座 Lesson 3: Make yourself at home 第 三 课 : 宾 至 如 归 L1 Male: 各 位 朋 友 好, 欢 迎 您 收 听 留 学 澳 洲 英 语 讲 座 节 目, 我 是 澳 大 利 亚 澳 洲 广 播 电 台 的 节 目 主 持 人 陈 昊 L1 Female: 各 位

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

Microsoft Word - 201110.doc

Microsoft Word - 201110.doc 2011 年 10 月 信 徒 交 通 月 刊 目 錄 一 本 期 目 錄 編 輯 室 1 二 牧 者 的 話 教 會 轉 化 -- 得 到 更 新 皮 袋 衣 立 凡 2 三 講 章 精 華 清 潔 的 心 思 -- 除 去 論 斷 講 員 衣 立 凡 / 賴 美 如 整 理 4 清 潔 的 心 思 -- 除 去 情 慾 講 員 葉 志 偉 / 林 慶 如 整 理 9 四 精 選 文 章 等 候

More information

Microsoft PowerPoint - 01_Introduction.ppt

Microsoft PowerPoint - 01_Introduction.ppt Hello, World C 程序设计语言 第 1 章章观其大略 孙志岗 sun@hit.edu.cn http://sunner.cn prf("hello,, world\n"); 超级无敌考考你 : 如何把 hello 和 world 分别打印在两行? 2004-12-19 A Tutorial Introduction 2 hello.c 打印华氏温度与摄氏温度对照表 计算公式 : C=(5/9)(

More information

Microsoft Word - 正文.doc

Microsoft Word - 正文.doc 3 Access 3.1 SharePoint SharePoint SharePoint 3.6 1 1.15 1 3.1 3.2 1 3.1 40 Access 3.2 2 ID / 3.3 3 3.4 3.5 3.3 / 3.4 3.5 3 41 4 / 6 3.6 3.6 5 1 40 24 3.7 3.7 6 3.8 * 3.8 2 42 Access 1.16 1 3.1 / 1 3.9

More information

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

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

More information

untitled

untitled 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

数据结构与算法 - Python基础

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

More information

( 含 要 ) 1-2 用 或 雇 用, 抑 或 有 無 俸 給 文 職 或 武 職, 政 官 或 事 官 均 屬 之, 其 不 以 具 備 人 資 格 為 限, 因 此 屬 於 最 廣 義 之 念 四 廣 義 念 之 依 服 24 條 之 規 定 : 本 於 受 有 俸 給 之 文 武 職, 及

( 含 要 ) 1-2 用 或 雇 用, 抑 或 有 無 俸 給 文 職 或 武 職, 政 官 或 事 官 均 屬 之, 其 不 以 具 備 人 資 格 為 限, 因 此 屬 於 最 廣 義 之 念 四 廣 義 念 之 依 服 24 條 之 規 定 : 本 於 受 有 俸 給 之 文 武 職, 及 本 學 習 重 點 研 讀 首 先 應 釐 清 不 同 規 對 與 職 人 念 的 定 義, 其 中 之 定 義 從 最 廣 義 廣 義 狹 義 到 最 狹 義 的 人, 都 會 牽 涉 到 規 適 用 上 的 不 同, 而 職 人 涵 蓋 範 圍 比 更 廣, 讀 者 應 注 意 兩 者 之 間 的 區 別 建 議 讀 者 與 考 生 於 開 始 研 讀 之 際, 利 用 本 之 內 容 確 實

More information

02

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

More information

Microsoft Word - unitmtg09.doc

Microsoft Word - unitmtg09.doc 目 錄 女 童 軍 訓 練 方 向... 1 八 項 綱 領... 1 小 隊 時 間... 3 集 會 編 排... 4 女 童 軍 組 全 年 活 動 計 劃 表... 5 第 一 週 集 會 主 題 : 認 識 女 童 軍 運 動... 6 第 二 週 集 會 主 題 : 履 行 誓 詞 與 規 律... 16 第 三 週 集 會 主 題 : 認 識 八 項 綱 領... 20 第 四 週 集

More information

101_

101_ 國 語 文 教 育 --- 文 學 小 博 士 ( 古 典 詩 詞 ) 日 期 三 年 級 送 友 人 之 京 上 學 期 詩 詞 題 目 孟 浩 然 君 登 青 雲 去, 予 望 青 山 歸 雲 山 從 此 別, 淚 濕 薜 蘿 衣 題 灞 池 王 昌 齡 開 門 望 長 川, 薄 暮 見 漁 者 ; 借 問 白 頭 翁 : 垂 綸 幾 年 也? 秋 浦 歌 李 白 白 髮 三 千 丈, 緣 愁

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

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

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

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

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

Microsoft Word - 澎湖田調報告_璉謙組.doc

Microsoft Word - 澎湖田調報告_璉謙組.doc 越 籍 新 住 民 妊 娠 醫 療 照 護 : 訪 談 李 亞 梅 女 士 組 長 : 郭 璉 謙 成 大 中 文 所 博 二 組 員 : 阮 壽 德 成 大 中 文 所 博 一 黃 榆 惠 成 大 中 文 所 碩 一 許 愷 容 成 大 中 文 所 碩 一 何 珍 儀 成 大 中 文 所 碩 一 指 導 老 師 : 陳 益 源 教 授 前 言 2009 年 03 月 21 日, 下 午 2 時 30

More information

封面故事 FENG MIAN GU SHI 32 基于课标 基于学生 提升英语课堂 封面图片 上海市闵行区第四幼儿园 现 代 学 校 37 回归本源 彰显特色 / 胡金芳 出版日期 2015 年 5 月 15 日 35 运用问题情境中的有效提问促进大班 幼儿的语言发展 / 胡金芳 双 月 刊 2015 年第 3 期 总第 63 期 教学实效 / 刘董娴 38 尊重差异 培养能力 提高体育教学实 效

More information

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

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

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

untitled

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

More information

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

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

华恒家庭网关方案

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

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

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

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

More information