Re: [又打] 擾了
6.16 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 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 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 sum appears. Print teh results in a
tabular format. Also, determine if the totals are reasonable; i.e.,
there are six ways to roll a 7, so approximately one-sixth of all
the rolls should be 7.
Fig 6.23 Dice rolling outcomes.
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
※ 引述《chinting (chinting)》之銘言:
: 各位生工系的大好人們
: 可以提供一下這次計算機程式的題目嗎
: 抱歉又麻煩了
: 因為我滿宅的
: 所以只能以100P幣(稅前)當做回報
: 謝謝~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.63.202
→
04/29 20:09, , 1F
04/29 20:09, 1F
推
04/29 20:23, , 2F
04/29 20:23, 2F
推
04/29 20:41, , 3F
04/29 20:41, 3F
推
04/29 22:28, , 4F
04/29 22:28, 4F
推
04/29 22:53, , 5F
04/29 22:53, 5F
推
04/29 22:57, , 6F
04/29 22:57, 6F
→
04/29 23:21, , 7F
04/29 23:21, 7F
→
04/29 23:24, , 8F
04/29 23:24, 8F
推
04/29 23:50, , 9F
04/29 23:50, 9F
推
04/30 00:15, , 10F
04/30 00:15, 10F
討論串 (同標題文章)