统计双色球红球出现概率的程序(10000次实验)

来源:互联网 发布:windows命令行进入c盘 编辑:程序博客网 时间:2024/05/16 03:22

import java.util.*;

public class Map1
{
 public static void main(String args[])
 {
  Random rand = new Random(47);
  Map<Integer,Integer> m = new HashMap<Integer,Integer>();
  for(int  i = 0; i <10000 ;i ++)
  {
   int r = rand.nextInt(16);
   r = r+1;
   Integer freq = m.get(r);
   m.put(r,freq == null ? 1 : freq+1);
  }
  System.out.println(m);
 }
}

 

输出

{1=602, 2=592, 3=633, 4=688, 5=594, 6=616, 7=607, 8=641, 9=577, 10=647, 11=668,
12=629, 13=632, 14=627, 15=636, 16=611}
 

原创粉丝点击