Part 2 31 32 33
106 107, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float f[size]; /* 10 /* c 10 /* f 20 3 1 1 arraytype arrayname [arraysize]; (type),,,,,, 5 const int MAX = 10; int array [MAX]; int array_size = 27; int A[6]; 2000 /* : const int array[array_size]; /* : Q uiz int err[45]; /* :
108 109 A6, 4 A 24 ( ),,, 0 (1) int a[20]; /* a [ 0 ] a [ 19 ] 20 float b[10]; /* b [ 0 ] b [ 9 ] 10 a[0] = 100; a[10] = 8; a[5] = a[4]; b [ 23] = 1011; b[a[10]] = 1012; a [ jk] = 4; /* a 100 /* a1 1 8 /* 5 a6 /* b[5] = 1011 /* a[10]8 b[8] = 1012 /* j k 4 int arr[4]; 4 4 4, 0 4 0 1, 2, 3 0 [ 3-2] 4, arr[4]=100; int a[10]; int b[10]; a b; /* a b, b a 4, 4, 4, double 8, 1, 0
110 111 #include <stdioh> int a[4] = 1, 2, 3, 4; char b[4] = a,b,c,d ; double c[4] = 111, 222, 333, 444; p r i n t f(a = % d,b = % d,c = % d \ n, s i z e o f ( a ),s i z e o f ( b ), sizeof(c)); p r i n t f(a [ 0 ] %u\n a[1] %u\n a[2] %u\n a[3] % u \ n, &a[0], &a[1], &a[2], &a[3]); sizeof( ), & sizeof( ), a[ ] 4byte 4, 16 b=4, c=32 int aa[size] 1, 5, 6, 8 ; int bb[size]; bb[size] aa[size]; /* bb[size] 2, 4, 6, 8 ; /*, 2,,,, arraytype arrayname [arraysize]; arraytype arrayname [arraysize][arraysize]; 1 2 a r r a y T y p e arrayname [arraysize][arraysize] [arraysize]; n 2 int arr[3][4]; [ 3-4], [ 3-4] [ 3-5] n #define SIZE 5
112 113, 1 6 60 360? 360 int kor 1, kor 2,, kor 360; 360, 0 59 1, 60 119 2, int kor[360]; 60 6 int first[60], second[60], six[60];, 6, 360? 2, 60 6 2 2,, kor60 1 6 2 3 2,, (garbage) 0 for #include <stdioh> int arr[5]; for( int i = 0; i < 5; i++ ) arr[i] = 0; for 0 0,
114 115 #include <stdioh> #define DAY_IN_WEEK 7 int j; float sum = 0; float temp[day_in_week]; 1 arraytype arrayname [arraysize] = ; (,) int arr[5] = 1, 2, 3, 4, 5 5 printf ( ( )\ n ); for(j = 0; j < DAY_IN_WEEK; j++) scanf (% f, &temp[j]); for(j = 0; j < DAY_IN_WEEK; j++) sum += temp[j]; p r i n t f ( = %f\n, sum/day_in_week); char arr[5] = h, e, l, l, o ; ( O ) char arr[5]; arr = h, e, l, l, o ; ( X ) arr[5] = h, e, l, l, o ; ( X ) int arr[50] = 3 ; 50 3, 0 [ 3-2] 7, for, for Q uiz, 0,,, 0
116 117 int arr[4] = 1, 2, 3, 4, 5; (too many initializers), 2, Q uiz int arr[3][4] = 1, 2, 3, 4, 5 int arr[][4] = 1, 2, 3, 4, 5, 6, 7, 8; 2 arr[2][4] int arr[][] = 1, 2, 3, 4, 5, 6, 7, 8; 2 int array[3][3] 1, 2, 3, 4, 5, 6, 7, 8, 9; 2 4 42 2, 3 array[0][0] 1 array[0][1] 2 array[0][2] 3 array[1][0] 4 array[1][1] 5 array[1][2] 6 array[2][0] 7 array[2][1] 8 array[2][2] 9 int array[3][3] 1, 2, 3, /* 4, 5, 6, /* 7, 8, 9; /*, 0 int sq[2][3] 5, 6, 5, 8; /* sq[0][0] 5 sq[0][1] 6 sq[0][2] 0 sq[1][0] 7 sq[1][1] 8 sq[1][2] 0 int arr[ ] = 1, 2, 3, 4 1 4, 4 memset( ) memset( ) memset( ) memset() : void * memset(void *s, int c, size_t n); s: c: i n t 1 ( c h a r ) n : : memh : #include <stdioh> #include <stringh> /* memset() int deck[52]; memset(deck, 0, sizeof(deck)); p r i n t f (1 0 deck[9] % d \ n, deck[9]);
118 119 [ 3-3] 0 d e c k [ 0 ]0, deck[1]0, deck[2]0,, deck[51]0 10 d e c k [ 9 ] = 0 C C char color[3] r e d ; char color[4] r e d ; '\0' int deck [5] 1, 2, 35, 4, 5; deck 35, 35 3 #include <stdioh> int f[15], n; f[0] = 1; f[1] = 1; p r i n t f (f[0] = %d\n, f[0]); p r i n t f (f[1] = %d\n, f[1]); for(n=2; n<15; n++) f[n] = f[n 2] + f[n1]; p r i n t f (f [% d ] = % d \ n, n, f[n]); [ 3-4], 1 f[0]=1; f [ 1 ] = 1 ;
120 121 n = ( n2) + (n1 ) 15, f [ n ] = f [ n2] + f[n1 ] int first[3][3], second[3][3], sum[3][3]; int i, j; p r i n t f ( \ n ); r e a d _ a r r ( f i r s t ) ; 3 3 p r i n t f (\ n \ n ); r e a d _ a r r ( s e c o n d ); 2 33 AB, AB ( C) for (i = 0; i < 3; i++) for(j = 0; j < 3; j++) sum[i][j] = first[i][j] + second[i][j]; p r i n t f (\ n + \ n ); p r i n t _ a r r ( s u m ) ; #include <stdioh> void read_arr(int M[3][3]) int i, j; for (i = 0; i < 3; i++) for(j = 0; j < 3; j++) p r i n t f ([ % d ][% d ] =, i+1, j+1); s c a n f (% d, &M[i][j]); void print_arr(int M[3][3]) int i, j; for(i = 0; i < 3; i++) for (j = 0; j < 3; j++) p r i n t f (% 4 d, M[i][j]); p r i n t f (\ n );
122 123 [ 3-5]33 2 first, second, sum int first[3][3]; 3 first, second, sum, 3 2 0, m m1 int first[3][3], second[3][3], sum[3][3]; read_arr( ), read_arr( ), p r i n t f ( \ n ); r e a d _ a r r ( f i r s t ) ; p r i n t f (\ n \ n ); r e a d _ a r r ( s e c o n d ) ; 2 1 (first, second, sum) 2 (first[1], first[2]) 2 int first[3][3]; read_arr( ), [3][3]2 void read_arr(int M[3][3]) int i, j; for (i = 0; i < 3; i++) for(j = 0; j < 3; j++) p r i n t f ([% d ][% d ] =, i+1, j+1); s c a n f (% d, &M[i][j]); for (i = 0; i < 3; i++) for(j = 0; j < 3; j++) sum[i][j] = first[i][j] + second[i][j]; print_arr( ) p r i n t f (\ n + \ n ); p r i n t _ a r r ( s u m ) ; print_arr( ) sum[ ] void print_arr(int M[3][3]) int i, j; for(i = 0; i < 3; i++) for (j = 0; j < 3; j++) p r i n t f (% 4 d, M[i][j]); p r i n t f (\ n );
124 125 #include <stdioh> int alpha(char c) if(c >= a&& c <= z ) return (c9 7 ) ; else if (c >= A&& c <= Z ) e l s e return (c6 5 ) ; return (1 ) ; int n, cha, alphabet[26]; char ch; for (n = 0; n < 26; n++) alphabet[n] = 0; [ 3-6], 1 int alpha(char c) if(c >= a&& c <= z ) return (c9 7 ) ; else if (c >= A&& c <= Z ) e l s e return (c6 5 ) ; return (1 ) ; 'a' 97, 'A'65 = a return (9797) = 0 = b return (9897) = 1 = D return (6865) = 3 while((ch = getchar())! = \ n ) cha = alpha(ch); if (cha!= 1) for (n = 0; n < 26; n++) if (n%10 == 0) a l p h a b e t [ c h a ] + + ; p r i n t f (\ n ); p r i n t f (% c :%5 d, n+65, alphabet[n]); c h a = a l p h a ( c h ) ; if (cha!= 1) a l p h a b e t [ c h a ] + + ; 10 if (n%10 == 0) p r i n t f (\ n ); p r i n t f (% c :%5 d, n+65, alphabet[n]); #include <stdioh> int leap(int year) if(year % 4 == 0 && year % 100!= 0 year % 400 == 0) return 29; else
126 127 return 28; int year, month, count, week, temp = 0; int mon[13] = 0,31,0,31,30,31,30,31,31,30,31,30,31; int i, k, n; char space = ; p r i n t f (year : ); s c a n f (% l d, &year); p r i n t f (month : ); s c a n f (% l d, &month); if(year*month == 0) p r i n t f (Input Error\n ); else if (month > 12 month < 0) e l s e p r i n t f (Input Error\n ); mon[2] = leap(year); for(i = 1; i < month; i++) temp += mon[i]; count = (year1)*365 + (year1 ) / 4( y e a r1)/100 + ( y e a r1)/400 + temp + 1; week = count % 7; p r i n t f (\ n % d% d\ n \ n, year, month); p r i n t f (\ n ); p r i n t f (% * c, 4*week, space); for(n = 1, k = week+1; n <= mon[month]; n++, k++) p r i n t f (%2d, n); if(k == 7) p r i n t f (\ n ); k = 0; year, month /* c o u n t w e e k temp = 0; /* /* /* * / int mon[13]=0,31,0,31,30,31,30,31,31,30,31,30,31; /* * / int i, k, n; /* char space = ; /* [ 3-7] (2002) (7), leap( ) 2 29, mon[2]=29 mon[0] for for, (2020) (7) (6) m o n [ 2 ] = l e a p ( y e a r ) ; for(i = 1; i < month; i++) temp += mon[i]; (count) count = + + 1 = 2019 + (temp) + 1 count = (year1)*365 + (year1)/4 ( y e a r1)/100 + (year1 ) / 4 0 0+
128 129 temp + 1; 7 3 20207 1 week = count % 7; 1 * 4*week, 4*3=12,, p r i n t f (% * c, 4*week, space); for 7 k 7 0, '\n' for(n = 1, k = week+1; n <= mon[month]; n++, k++) p r i n t f (% 2d, n ); if(k == 7) p r i n t f (\ n ); k = 0; #include <stdioh> #define NODE 6 #define M 4 0 0 0 int data[node][node] = 0, 6, M, 3, M, M, 6, 0, 1, 1, M, M, M, 1, 0, 5, 2, 5, 3, 1, 5, 0, 4, M, M, M, 2, 4, 0, 4, M, M, 5, M, 4, 0 ; int start, end, min, i, j, k; int v[node], distance[node]; p r i n t f (\ n : ); s c a n f (% d, &start); p r i n t f ( : ); s c a n f (% d, &end); for(j = 0; j < NODE; j++) v[j] = 0; distance[j] = M; d i s t a n c e [ s t a r t1] = 0; for(i = 0; i < NODE; i++) min = M; for(j = 0; j < NODE; j++) if(v[j] == 0 && distance[j] < min) k = j; min = distance[j];
130 131 v[k] = 1; if(min == M) break; for(j = 0; j < NODE; j++) p r i n t f ( if(distance[j] > distance[k] + data[k][j]) distance[j] = distance[k] + data[k][j]; % d % %d \n, start, end, d i s t a n c e [ e n d1 ] ) ; Dijkstra 1 (4 ) (3), (2, 3, 5) (1) (2), 1, ( ) ( )66 0 6 M 3 M M, 6 0 1 1 M M M 1 0 5 2 5 3 1 5 0 4 M M M 2 4 0 4 M M 5 M 4 0 M " " 0 0 int start, end, min, i, j, k; int v[node], distance[node]; start, end, min, v, distance[node] for(j = 0; j < NODE; j++) v[j] = 0; distance[j] = M; for, d i s t a n c e [ s t a r t1] = 0; 0 for(i = 0; i < NODE; i++) min = M; for(j = 0; j < NODE; j++) if(v[j] == 0 && distance[j] < min) k = j; min = distance[j];
132 133 v[k] = 1; if(min == M) break; for(j = 0; j < NODE; j++) if(distance[j] > distance[k] + data[k][j]) distance[j] = distance[k] + data[k][j]; 2 a[3][3], b[3][3], a, b 1 c[10] 10, enter, / 0 9 ( ) ( ), ) (10) arr[4][6], 100 2 a[3][3] 1 9 7 ( 1 b[10], 1~10,