c 语言 两个编程小题目 望解答!!!!!!
Writeaprogramthatsimulatestherollingoftwodice.Theprogramshoulduserandtorollthefirstdi...
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: Each die can show an integer value from 1 to 6, so the sum of the two values will vary from 2 to 12.
Figure: 36 Combinations of 2 dice
There are 36 possible combinations of the two dice. Your program should roll the two dice 36,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Print the 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).请大神们解答!!!!!!! 展开
Figure: 36 Combinations of 2 dice
There are 36 possible combinations of the two dice. Your program should roll the two dice 36,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Print the 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).请大神们解答!!!!!!! 展开
2个回答
展开全部
我来说一下题目的意思吧:
投掷色子 36000次
每次投掷2个,并计算两个色子的点数桐亏和
最后会发现点数和带轮搏为7的次数最多
思路
写一个投掷两个色子的程序
写一个6*6的色子结果数组,对应两个色子出现的情况,
如1,1 对应 a[0][0]
如4,6 对应 a[3][5]
3. 按副斜对角线方向计算点数和
示例
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
蠢祥 .。。。。。。
追问
那你能写出这个程序吗?
追答
说真的,程序不是很难,但是我只想说明思路。楼主自己编写比较好哦,编程学习重要的是自己编写(那样子技术提升才快,还会有成就感,要是写程序时遇到问题,再问人也不迟)。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询