Re: [又打] 擾了

看板NTUBSE-B-98作者時間14年前 (2010/04/29 20:09), 編輯推噓7(703)
留言10則, 8人參與, 最新討論串2/2 (看更多)
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
啊 不用給我P幣
04/29 20:09, 1F

04/29 20:23, , 2F
不知道幹嘛給P幣= =
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
心意點零B12
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
文章代碼(AID): #1BsNRriN (NTUBSE-B-98)
討論串 (同標題文章)
本文引述了以下文章的的內容:
又打
0
4
完整討論串 (本文為第 2 之 2 篇):
又打
0
4
又打
7
10
文章代碼(AID): #1BsNRriN (NTUBSE-B-98)