Generating truth tables in Java

后端 未结 7 546
悲哀的现实
悲哀的现实 2021-01-02 16:42

I\'m trying to print some truth tables as part of a school assignment. How can I generate a dynamic size truth table in Java?

So that printTruthTable(1)

7条回答
  •  耶瑟儿~
    2021-01-02 17:07

    This is not a truth table - rather, it's a table of binary numbers. You can use Java's Integer.toBinaryString method to generate the zeros and ones that you need; inserting spaces should be trivial.

    int n = 3;
    for (int i = 0 ; i != (1<

提交回复
热议问题