作者DKer ()
看板NTUBSE-B-98
標題Re: [又打] 擾了
時間Thu Apr 29 20:09:23 2010
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
→ DKer :啊 不用給我P幣 04/29 20:09
推 b98602008 :不知道幹嘛給P幣= = 04/29 20:23
推 damit123 :一種心意阿 04/29 20:41
推 belovelee :一種回報阿 04/29 22:28
推 todd7930 :一種愛情阿 04/29 22:53
推 sean1990shi :____阿斯~~~~~~ 04/29 22:57
→ DKer : 心意點零B12 04/29 23:21
→ dannyace :蛤? 04/29 23:24
推 chinting :感謝囉~那我就不送了~果然是有情有義生工人 04/29 23:50
推 chinting :啊是助教耶 04/30 00:15