Java / Demorgan's Law /布尔代数/随机骰子/

时间:2015-12-08 07:40:05

标签: java random static demorgans-law boolean-algebra

我需要一些帮助才能使此代码正常工作。

我需要能够编写一个程序来计算必须滚动三个六面骰子的次数,直到显示的值都不同为止。

说明:

编写一个生成10次输出的驱动程序。

以下是两个输出运行的示例。

2 6 5

count = 1

5 3 5

3 5 3

3 3 4

1 3 3

2 5 4

count = 5

到目前为止,这是我的代码,我并不完全知道在何处以及如何应用DeMorgan法律。

import java.util.Random;
 public class P4_Icel_Murad_Rolling
{
    public static void main(String[] args){
        P4_Icel_Murad_Rolling obj = new P4_Icel_Murad_Rolling();
        obj.rolling(10);
    }

    public void rolling(int number){
        int counter = 0;
        Random num = new Random();
        for(int i = 0; i < number; i++){
          int A = num.nextInt(6);
          System.out.print(A + " ");
          int B = num.nextInt(6); 
          System.out.print(B + " ");
          int C = num.nextInt(6); 
          System.out.print(C + " ");
          if((){
            counter++;
            }
          System.out.println();
        }        
    }


}

1 个答案:

答案 0 :(得分:0)

试试这个: (我不知道在这里应用de Morgan定律很热。)

{{1}}