Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. class Matrix1 {
  2.     private boolean[][] a;
  3.     private boolean[][] b;
  4.     //private boolean[][] c;
  5.     private boolean[][] c = new boolean [3][3];
  6.    
  7.     //private   boolean[][] c = {{false, false, false}, {true, true, true}, {false, true, true}};
  8.  
  9.  
  10.  
  11.  
  12.     public Matrix1 (boolean[] [] a, boolean[] [] b)
  13.     {
  14.         this.a = a;
  15.         this.b = b;
  16.     }
  17.  
  18.     public boolean [][] multiplyMatrix(boolean[][] a, boolean[][] b, boolean[][] c) {
  19.        
  20.         this.a = a;
  21.         this.b = b;
  22.         this.c = c;
  23.        
  24.         for (int i = 0; i < a.length; i++) {
  25.             for (int j = 0; j < a.length; j++) {
  26.                 for (int k = 0; k < a.length; k++) {
  27.                     c[i][j] = c[i][j] & (a[i][k] | b[k][j]);
  28.  
  29.                     //c[i][j] = true;
  30.                 }
  31.             }
  32.         }
  33.        
  34.         return c;
  35.     }
  36.    
  37.  
  38.     public String toString () {
  39.     String str = "";
  40.  
  41.  
  42.         int l, n;
  43.         for (l = 0; l < a.length; l++)
  44.         {
  45.             for (n = 0; n < a.length; n++)
  46.             {
  47.             str = str + " " + c[l][n];
  48.             }
  49.             str = str+ "\n";
  50.         }
  51.     return str;
  52.     }
  53. }
  54.  
  55. public class Test {
  56.     public static void main(String[] args) {
  57.         boolean [][] aa = {{true, true, true}, {true, true, true}, {true, true, true}};
  58.         boolean [][] bb = {{true, true, true}, {true, true, true}, {true, true, true}};
  59.  
  60.         Matrix1 m = new Matrix1 (aa, bb);
  61.        
  62.         System.out.println(m);
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement