-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.java
45 lines (39 loc) · 1.25 KB
/
Utils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.assisgnment;
/**
*
* @author njain yeah otherwise biases of superiorty takes over.
*/
public class Utils {
public static void recurseAdd(int[][] C, int[][] A, int[][] B, int rowC, int colC) {
int n = A.length;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
C[i + rowC][j + colC] = A[i][j] + B[i][j];
}
}
}
public static int[][] add(int[][] A, int[][] B) {
int n = A.length;
int[][] result = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
result[i][j] = A[i][j] + B[i][j];
}
}
return result;
}
public static int[][] subtract(int[][] A, int[][] B) {
int n = A.length;
int[][] result = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
result[i][j] = A[i][j] - B[i][j];
}
}
return result;
}
}