Example #1
0
 /**
  * Reads a 1D array of booleans from standard input and returns it.
  *
  * @return the 1D array of booleans
  */
 public static boolean[] readBoolean1D() {
     int n = StdIn.readInt();
     boolean[] a = new boolean[n];
     for (int i = 0; i < n; i++) {
         a[i] = StdIn.readBoolean();
     }
     return a;
 }
Example #2
0
 /**
  * Reads a 2D array of booleans from standard input and returns it.
  *
  * @return the 2D array of booleans
  */
 public static boolean[][] readBoolean2D() {
     int m = StdIn.readInt();
     int n = StdIn.readInt();
     boolean[][] a = new boolean[m][n];
     for (int i = 0; i < m; i++) {
         for (int j = 0; j < n; j++) {
             a[i][j] = StdIn.readBoolean();
         }
     }
     return a;
 }