September 19, 2013
140

# C Lecture 2013.09.19

September 19, 2013

## Transcript

18. ### ຊ೔ͷ͓͠ͳ͕͖ • ϓϩάϥϛϯάͱ͸ • Cͷجૅ • ม਺ • ੍ޚߏจ •

഑ྻ/ߏ଄ମ • ϙΠϯλ • ؔ਺ • ԋश

35. ### \$ emacs hello.c --- #include <stdio.h> int main() { printf(“Hello,

world!\n”); return 0; }

73. ### a b a < b 0 0 0 0 1

1 1 0 0 1 1 0

whileͷ্Ґ൛

80. ### int a = 10; int b = 20; if (

a < b ) { printf(“%d\n”, b); } else { printf(“%d\n”, a); }
81. ### int a = 10; int b = 20; if (

a > b ) { printf(“%d\n”, b); } else { printf(“%d\n”, a); }

85. ### int i = 10; printf(“%d\n”, i); i = i -

1; printf(“%d\n”, i); i = i - 1; ...

88. ### int i = 10; // i: 10 int tmp =

i - 1; // i: 10 i = tmp; // i: 9
89. ### int i = 10; printf(“%d\n”, i); i = i -

1; printf(“%d\n”, i); i = i - 1; ...
90. ### int i = 10; while ( 0 < i )

{ printf(“%d\n”, i); i = i - 1; }

93. ### int i = 10; while ( 0 < i )

{ printf(“%d\n”, i); i = i - 1; }
94. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); }
95. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); }
96. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); }
97. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10
98. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10
99. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10
100. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9
101. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9
102. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9
103. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8
104. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8
105. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8
106. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7
107. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7
108. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7
109. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6
110. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6
111. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6
112. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5
113. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5
114. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5
115. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4
116. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4
117. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4
118. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3
119. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3
120. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3
121. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2
122. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2
123. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2
124. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2 1
125. ### int i; for (i = 10; 0 < i; i

= i - 1) { printf(“%d\n”, i); } 10 9 8 7 6 5 4 3 2 1

132. ### int a0 = 3; ... int a6 = 22; int

a7 = 24; int a8 = 27;

134. ### int a[100]; a[0] = 3; ... a[6] = 22; a[7]

= 24; a[8] = 27;

ఴࣈ ] = ஋;

147. ### ໊લ ೥ྸ ਎௕ ମॏ Ұ࿠ 19 165 59 ೋ࿠ 20

172 64 ࡾ࿠ 21 183 72 ࢛࿠ 16 159 53
148. ### struct brother { int age; double height; double weight; };

// ηϛίϩϯΘ͢Εͣʹ
149. ### struct brother ichiro; ichiro.age = 19; ichiro.height = 165; ichiro.weight

= 59; printf(“%d\n”, ichiro.age); // 19
150. ### struct brother ichiro; ichiro.age = 19; ichiro.height = 165; ichiro.weight

= 59; printf(“%d\n”, ichiro.age); // 19
151. ### brother ichiro; ichiro.age = 19; ichiro.height = 165; ichiro.weight =

59; printf(“%d\n”, ichiro.age); // 19

weight; };
155. ### typedef struct { char name[20]; int age; double height; double

weight; } brother;

161. ### int sq (int num) { return num * num; }

int main(){ int a = 3; printf(“%d\n”, sq(a)); return 0; }
162. ### Math: f(x) = x * x C: int sq (int

num) { return num * num; }
163. ### Math: f(x) = x * x C: int sq (int

num) { return num * num; }
164. ### Math: f(x) = x * x C: int sq (int

num) { return num * num; }
165. ### Math: f(x) = x * x C: int sq (int

num) { return num * num; }
166. ### Math: f(x) = x * x C: int sq (int

num) { return num * num; }
167. ### int sq (int num) { return num * num; }

ܕ ؔ਺໊ ( ܕ Ҿ਺ ) { ॲཧ ؔ਺ͷܕʹ߹ͬͨฦΓ஋ }
168. ### int sq (int num) { return num * num; }

ܕ ؔ਺໊ ( ܕ Ҿ਺, ܕ Ҿ਺ ) { ॲཧ ؔ਺ͷܕʹ߹ͬͨฦΓ஋ }
169. ### int sq (int num) { return num * num; }

int main(){ int a = 3; printf(“%d\n”, sq(a)); return 0; }

9

ϙΠϯλ

&͸ม਺ͷ”৔ॴ”Λࣔ͢

= 1;
179. ### // ϙΠϯλͷએݴ // “৔ॴ”ΛೖΕΔม਺ int *b_button; b_button = &button; button

= 1; printf(“%d\n”, *b_button); // 1

182. ### void sq (int *num1, int *num2) { num1 = &a;

num2 = &b; *num1 = *num1 * *num1; *num2 = *num2 * *num2; } int main(){ int a = 3, b = 6; sq(&a, &b); printf(“%d, %d\”, a, b);