首页 > 其他 > 详细

quick 均衡真随机数

时间:2015-05-02 12:26:06      阅读:304      评论:0      收藏:0      [点我收藏+]
math.randomseed(tostring(os.time()):reverse():sub(1, 6))
local sum1=0
local sum2=0
local sum3=0
local sum4=0
for i=1,100 do
    local num=math.random(1,4)
    if math.ceil(num)==1 then
        sum1=sum1+1
    end
    if math.ceil(num)==2 then
        sum2=sum2+1
    end
    if math.ceil(num)==3 then
        sum3=sum3+1
    end
    if math.ceil(num)==4 then
        sum4=sum4+1
    end

end

print(sum1)
print(sum2)
print(sum3)
print(sum4)

 

quick 均衡真随机数

原文:http://www.cnblogs.com/yufenghou/p/4471776.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!