测试面试题

2013-03-21  刘俊 

A,B两人扔骰子,A先扔,B比A大的概率是多少?怎么建模?
 
arr=[]
a=rand(1..6)
b=(6.00-a)/6.00
print "如果A掷出#{a}点,那么B胜出的概率是: "
puts (6-a).to_s+"/6"
6.times do |i|
  if (i+1)>a && (i+1)<=6
    arr.push i+1
  end
end
print "可能情况是:"
p arr
print "B赢的概率是:"
print (b*100).round.to_s+'%'
puts
 
不会建模。。。
352°/3484 人阅读/4 条评论 发表评论

熊志男  2013-04-02

which company?


刘俊  2013-04-04

熊志男: which company?
电信


甘隆琴  2013-04-08

对我来说是高难度。。。


晏佳  2013-04-09

这是要概率建模呀


登录 后发表评论