我正在开发一个显示随机数的图灵应用程序,然后显示该数字滚动了多少次,然后找到模式,随机滚动次数的最大值,并显示哪个数字(1- 6) 滚动最多。谢谢您的帮助。
var numberDice : int
var freq : array 1 .. 6 of int
var highestNum : int
highestNum := 0
for j : 1 .. 6
freq (j) := 0
end for
for i : 1 .. 25
randint (numberDice, 1, 6)
freq (numberDice) := freq (numberDice) + 1
end for
for counter : 1 .. 6
if freq (counter) > highestNum then
highestNum := freq (counter)
end if
end for
put "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
put "Number Frequency"
put "1 ", freq (1)
put "2 ", freq (2)
put "3 ", freq (3)
put "4 ", freq (4)
put "5 ", freq (5)
put "6 ", freq (6)
put " "
put "Mode: ", highestNum
put "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"