3D彩票所有和值出现的概率

//计算3D彩票所有和值出现的概率        
        for(int l = 0;l <= 27;l++) {
            int count = 0;
            float gs = 0;
            for (int i = 0;i < 10;i++) {
                for (int j = 0;j < 10;j++) {
                    for (int k = 0;k < 10;k++) {                        
                        count++;    //这一步停止以后a++,并且输出gs,然后向上进行第二个for循环
                        if (i+k+j == l)    {
                            gs++;
                        }
                        
                        }                            
                    }
                }    
            System.out.println(l + "的概率 = " + gs / count * 100 + " %");    
            }

猜你喜欢

转载自www.cnblogs.com/shaonianteng/p/10391560.html