You are on page 1of 1

public class Codigo {

private int[][]a;
private int[][]b;
private int nfa,nca,nfb,ncb;

public Codigo(int[][] a, int[][] b, int nfa, int nca, int nfb, int ncb) {
this.a = a;
this.b = b;
this.nfa = nfa;
this.nca = nca;
this.nfb = nfb;
this.ncb = ncb;
}

public int[][] junta() {


int[][] res = new int[nfa][nca];
for (int i = 0; i < nfa; i++) {
for (int j = 0; j < nca; j++) {
res[i][j] = a[i][j] + b[i][j] - a[i][j] * b[i][j];
}
}

return res;
}

public int[][] reunion() {


int[][] res = new int[nfa][nca];
for (int i = 0; i < nfa; i++) {
for (int j = 0; j < nca; j++) {
res[i][j] = a[i][j] * b[i][j];
}
}

return res;
}

public int[][] productoBooleano() {


int[][] res = new int[nfa][ncb];
for (int i = 0; i < nfa; i++) {
for (int j = 0; j < ncb; j++) {
int sum = 0;
for (int k = 0; k < nca; k++) {
sum += a[i][k] * b[k][j];
}
if (sum > 1) {
res[i][j] = 1;
}
}
}
return res;
}

You might also like