作者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
1F:→ DKer :啊 不用给我P币 04/29 20:09
2F:推 b98602008 :不知道干嘛给P币= = 04/29 20:23
3F:推 damit123 :一种心意阿 04/29 20:41
4F:推 belovelee :一种回报阿 04/29 22:28
5F:推 todd7930 :一种爱情阿 04/29 22:53
6F:推 sean1990shi :____阿斯~~~~~~ 04/29 22:57
7F:→ DKer : 心意点零B12 04/29 23:21
8F:→ dannyace :蛤? 04/29 23:24
9F:推 chinting :感谢罗~那我就不送了~果然是有情有义生工人 04/29 23:50
10F:推 chinting :啊是助教耶 04/30 00:15