: (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 2293624 2293628 var[2] 179
(1) ( ) int a = 3; int b = 5; int c = 0; int max = a; if (b > max) { max = b; } if (c > max) { max = c; } printf( %d.\n, max); ( 1) int v[3]; v[0] = 3; v[1] = 5; v[2] = 0; int max = v[0]; if (v[1] > max) { max = v[1]; } if (v[2] > max) { max = v[2]; } printf( %d.\n, max); max3_1.cpp max3_2.cpp 180
(dice_2.cpp) 6000 1 ~ 6 (dice_3.cpp) : long rand() [stdilb.h] : rand() % 6 + 1 : 181
: [ ] = {,,,..., }; 0 : int v[3] = {3, 5}; v[0] v[1] v[2] 3 5 int v[] = {3, 5, 0}; int v[3] = {3, 5, 0}; 0 2293620 2293624 2293628 dice_5.cpp 182
(2) [for] ( 2) int v[3] = {3, 5, 0}; int max = v[0]; if (v[1] > max) { max = v[1]; } if (v[2] > max) { max = v[2]; } printf( %d.\n, max); ( X ) int v[3] = {3, 5, 0}; int max = v[0]; for (int i = 1; i < 3; ++i) { if (v[i] > max) { max = v[i]; } } printf(" %d.\n", max); 0 max3_3.cpp dice_6.cpp 183
(3) [switch] switch: 内 switch(dice) { case 1: count[0]++; break; case 2: count[1]++; break; case 3: count[2]++; break; case 4: count[3]++; break; case 5: count[4]++; break; case 6: count[5]++; break; } count[dice-1]++; dice_7.cpp 184
coin_1.cpp coin_2.cpp : 5 1 5 5 4 1 411 price[5] 1 90 2 75 3 83 4 89 5 71 185
(hist.cpp) (0~59, 60~69, 70~79, 80~89, 90~100) : 5 1 : 80 2 : 85 3 : 90 4 : 95 5 : 75 0~ 59 : 60~ 69 : 70~ 79 : * 80~ 89 : ** 90~100 : ** 186
C ( ) int var[3]; var == 2293620 2293620 var[0] var[1] 2293624 2293628 var[2] : int max(int v[]); 187
max_1.cpp max_2.cpp max1v int max1v( int [5] ); max_2.cpp max_3.cpp max2v int max2v( int [], int N); 188
\0 (char) ( ): A ( ): ABC ABC { A, B, C, \0 } (\0 ) ( ) : char [ ] = ; (char) A (char) B (char) C ( \0 ) (char) \0 2293620...21...22...23 scanf printf scanf printf %s char string[] = Hello world ; printf( %s, string); scanf( %s, string); [ scanf &] scanf 189
(strlen) : \0 ( 100): len len 3 190
C C <string.h> : strcpy(, ) strcat(, ) int strcmp(, ) 0 size_t strlen( ) NULL ( \0 ) 191
(max_grade.cpp) quit Please enter the name : John Please enter the grade: 80 Please enter the name : Mary Please enter the grade: 70 Please enter the name : Stephen Please enter the grade: 90 Please enter the name : David Please enter the grade: 60 Please enter the name : quit Best: Stephen (90) 192
(sort) i=0 i=1 i=2 i=3... 9 7 5 10 3 8 4 3 7 5 10 9 8 4 3 4 5 10 9 8 7 3 4 5 10 9 8 7 sort_1.cpp 193
int var[3] ; int var[2][3]; var[0] var[1] var[2] 2293620 2293624 2293628 var[0][0] var[0][1] var[0][2] 2293620 2293624 2293628 var[1][0] var[1][1] var[1][2] 2293632 2293636 2293640 var == 2293620 var == 2293620 var[0] == 2293620 var[1] == 2293632 194
(card.cpp) 52 S, H, D, C D12 H1 D4 C3... 195
(1) [E0601] [E0602] ( ) [E0603] (Not 196
(2) [E0604] 2012 2012 1 1 2 29 (1~12): 3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 197
(3) [E0605] 123 A B C Player #1: Please enter your choice: 2A 123 A O B C Player #2: Please enter your choice: 2B 123 A O B X C 198
(4) [E0606] 5 0 ~ 9 [E0607] : Please enter your name: Ken-Yi Lee Hello, KEN-YI LEE! \0 a z <ctype.h> islower() - a + A <ctype.h> toupper() 199
200