``` 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313``` ```1 00:00:00,000 --> 00:00:03,160 >> DAVID J. Malan: Sipoze nou vle ekri yon pwogram ki mande tout moun nan 2 00:00:03,160 --> 00:00:06,740 yon chanm pou laj yo, ak Lè sa a, simagri konnen kouman fin vye granmoun moun sa yo pral gen yon 3 00:00:06,740 --> 00:00:07,520 ane kon sa? 4 00:00:07,520 --> 00:00:09,900 Koulye a, evidamman aritmetik la pou sa a pwoblèm a pwal san patipri 5 00:00:09,900 --> 00:00:10,660 dwat. 6 00:00:10,660 --> 00:00:14,090 Men, kesyon an enteresan an se, si nou pa konnen an davans konbyen moun ki 7 00:00:14,090 --> 00:00:16,790 yo ale nan dwe nan sal sa a, ki jan nou te ka ale sou estoke 8 00:00:16,790 --> 00:00:17,980 tout ki gen laj ki yo? 9 00:00:17,980 --> 00:00:19,680 Oke, kite la pran yon gade. 10 00:00:19,680 --> 00:00:22,760 >> Se pou nou kòmanse pa premye pouse nan itilizatè, menm jan mwen te fè isit la, pou la 11 00:00:22,760 --> 00:00:26,410 kantite moun ki nan sal la lè l sèvi avèk getInt ak yon bouk fè-pandan ke yo nan lòd yo 12 00:00:26,410 --> 00:00:28,220 jwenn yon n nonb antye ki pè. 13 00:00:28,220 --> 00:00:32,310 Sipoze kounye a nou vle mande chak sa yo moun ki nan sal la pou laj yo. 14 00:00:32,310 --> 00:00:35,820 Oke, ensten mwen ta dwe sèvi ak yon bouk fè sa pouse, men mwen tou 15 00:00:35,820 --> 00:00:37,840 bezwen yon kote nan magazen ki gen laj moun sa yo la. 16 00:00:37,840 --> 00:00:40,760 Apre sa, ensten premye fwa mwen ta gen sèvi ak yon varyab pou premye a 17 00:00:40,760 --> 00:00:43,690 laj moun nan, yon lòt varyab pou laj moun nan dezyèm la, 18 00:00:43,690 --> 00:00:44,780 sòt de sou liy. 19 00:00:44,780 --> 00:00:46,230 Int gen laj - 20 00:00:46,230 --> 00:00:48,850 Oke, kite la rele l '1 pou premye moun la. 21 00:00:48,850 --> 00:00:51,480 Int laj 2 an pou moun, dezyèm lan. 22 00:00:51,480 --> 00:00:53,980 Int laj 3 zan pou moun nan twazyèm. 23 00:00:53,980 --> 00:00:56,750 >> Men, tann yon minit, sa a se pa petèt chemen an pi byen ale desann. 24 00:00:56,750 --> 00:01:00,620 Paske mwen pa konnen nan avanse, ki se ekri ak konpile pwogram sa a ki jan 25 00:01:00,620 --> 00:01:02,330 anpil divinò gen yo ale nan dwe. 26 00:01:02,330 --> 00:01:06,590 Apre sa, Anplis, si gen nan anpil jan 100 itilizatè yo, deklare 100 varyab 27 00:01:06,590 --> 00:01:10,350 sòt de etranj yo te rele tankou sa a pa fè sa santi tankou desen an trè pi byen. 28 00:01:10,350 --> 00:01:14,430 >> Oke, Erezman gen egziste yon lòt di ki kalite varyab rele yon etalaj ki 29 00:01:14,430 --> 00:01:18,710 pèmèt nou nan magazen nenpòt ki kantite antye andedan nan li, menm si nou pa konnen 30 00:01:18,710 --> 00:01:22,190 lè li ap ekri pwogram mwen an ki jan anpil antye sa yo nou pral bezwen. 31 00:01:22,190 --> 00:01:25,970 Se konsa, kite a rvnir ak efase sa yo plizyè antye, ak olye ranplase li 32 00:01:25,970 --> 00:01:29,620 ak yon varyab rele, di, laj, pliryèl. 33 00:01:29,620 --> 00:01:33,420 Men, kite a plis presize sou liy sa a nan kòd nan parantèz kare ke nou 34 00:01:33,420 --> 00:01:35,460 vle antye n. 35 00:01:35,460 --> 00:01:39,570 Se poutèt sa, n ap ansanm al gade nan antye sa yo kòm laj. 36 00:01:39,570 --> 00:01:43,490 >> Koulye a, nan jis yon ti moman mwen pral kapab jwenn nan chak nan antye yo nan etalaj sa a 37 00:01:43,490 --> 00:01:47,270 Menm jan an tou pa fason pou bracket kare notasyon, kòmanse nan 0. 38 00:01:47,270 --> 00:01:51,720 Se konsa, kite a kontinye kounye a nan yon bouk de motive-itilizatè yo pou laj yo. 39 00:01:51,720 --> 00:01:54,780 Pou Int mwen jwenn 0. 40 00:01:54,780 --> 00:01:59,464 Mwen se mwens pase N, kantite moun ki nan chanm nan, mwen plis plis. 41 00:01:59,464 --> 00:02:06,610 >> Epi, koulye a nan sa a bouk, se pou yo di printf laj ki gen nimewo moun, pousan mwen 42 00:02:06,610 --> 00:02:09,430 se yon kontneur, vigil. 43 00:02:09,430 --> 00:02:13,210 Epi, koulye a, olye ke kòmanse konte soti nan 0 nan pwogram nan tèt li, se pou yo nan 44 00:02:13,210 --> 00:02:17,180 pi piti mwen enkreman pa 1 pou ke yon nòmal moun lè l sèvi avèk pwogram sa a 45 00:02:17,180 --> 00:02:20,120 pa gen yo konte tankou yon syantis òdinatè fòs. 46 00:02:20,120 --> 00:02:26,130 Se pou nou fè kounye a laj, bracket mwen, kidonk ki espesifye ke laj yo m-th nan nou an 47 00:02:26,130 --> 00:02:31,480 etalaj de laj ki pral jwenn valè a retounen nan getInt. 48 00:02:31,480 --> 00:02:37,800 >> Koulye a, pi ba a sa a bouk, se pou yo kontinye ou panse ke kèk tan pase. 49 00:02:37,800 --> 00:02:41,690 Li kite yo kounye a kontinye nan yon lòt bouk ki aktyèlman gen laj tout moun nan chanm nan 50 00:02:41,690 --> 00:02:42,800 pa yon ane. 51 00:02:42,800 --> 00:02:48,110 Se konsa, ankò, pou Int mwen jwenn 0, mwen ki pi piti a pase N, kantite moun ki nan la 52 00:02:48,110 --> 00:02:49,680 chanm nan, mwen plis plis. 53 00:02:49,680 --> 00:02:57,210 >> Epi, koulye a andedan nan sa a bouk, se pou yo di printf yon ane nan kounye a nimewo moun, 54 00:02:57,210 --> 00:03:00,990 pousan mwen se yon kontneur, yo pral dwe, pousan mwen se yon lòt 55 00:03:00,990 --> 00:03:03,210 kontneur, ane fin vye granmoun. 56 00:03:03,210 --> 00:03:07,230 Lè sa a, ploge nan sa yo placeholders, se pou yo premye di mwen plis 57 00:03:07,230 --> 00:03:11,220 1, se konsa ke ankò nou kòmanse konte pou itilizatè a soti nan 1. 58 00:03:11,220 --> 00:03:18,630 Lè sa a, se pou yo ploge nan laj moun sa a kòm laj bracket mwen plis 1, kidonk 59 00:03:18,630 --> 00:03:23,740 ki espesifye ale jwenn laj la m-th nan nou an etalaj de laj, ajoute 1 sou li, ak Lè sa a, 60 00:03:23,740 --> 00:03:28,370 insert ki sòm nan kontneur nou an, paren fèmen, pwenvigil. 61 00:03:28,370 --> 00:03:33,280 >> Se pou nou kounye a konpile pwogram sa a ak fè laj, e kite yo kouri l 'ak dot 62 00:03:33,280 --> 00:03:34,990 koupe laj. 63 00:03:34,990 --> 00:03:38,770 Apre sa, ta kwè ke gen sèlman twa moun ki nan sal la, ak yon moun se 18, 64 00:03:38,770 --> 00:03:40,700 yon moun se 19, yon moun a se 20. 65 00:03:40,700 --> 00:03:45,350 Oke, nan yon ane, yo chak nan sa yo folks a pwal 19, 20, ak 21, 66 00:03:45,350 --> 00:03:46,600 respektivman. 67 00:03:46,600 --> 00:03:48,948 ```