看板 NTUBSE-B-96 關於我們 聯絡資訊
Write a program that simulates the rolling of two dice. The program should use rand to roll the first die, and should use rand again to roll the second die. The sum of the two values should then be calculated. [Note: Since each die can show an integer value from 1 to 6, then the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 the least frequent sums.] Figure 6.23 shows the 36 possible combinations of the two dice . Your program should roll the two dice 36,000 times. Use a single-subscripted array to tally the numbers of times each possible there are six ways to roll a 7, so approximately on-sixth of all the rolls should be 7. 1 2 3 4 5 6 1 2 3 4 5 6 7 2 3 4 5 6 7 8 3 4 5 6 7 8 9 4 5 6 7 8 9 10 5 6 7 8 9 10 11 6 7 8 9 10 11 12 Fig.6.23|Dice rolling outcomes -- 如果我們具有磁場, 則當我們每次經過電冰箱門的時候, 我們都可能會與冰箱門撞在一起, 所以人的身體不具有磁場是有其優點的。 節錄自Fundamentals of Physics 7ed by Halliday&Resnick&Jearl Walker -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.242.26
kerott:中文版6.19喔~ 04/27 19:53