From 5b99b54543227bd2ca1e1ba959e4d4ab613d40b8 Mon Sep 17 00:00:00 2001 From: aidanrahill <116307633+aidanrahill@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:29:07 -0700 Subject: [PATCH 1/2] Reverting Old Commit --- MatrixExample.java | 6 ++++-- README.md | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/MatrixExample.java b/MatrixExample.java index cfd9e30..051e5bc 100644 --- a/MatrixExample.java +++ b/MatrixExample.java @@ -39,12 +39,14 @@ public static int[][] multiplyMatrices(int[][] matrix1, int[][] matrix2) { "Number of columns in the first matrix must be equal to the number of rows in the second matrix."); } - int[][] result = new int[rows1][cols2]; + // Some more issues here too + int[][] result = new int[rows1+1][cols2+1]; + // Lots of issues with this code, it used to be working perfectly though for (int i = 0; i < rows1; i++) { for (int j = 0; j < cols2; j++) { for (int k = 0; k < cols1; k++) { - result[i][j] += matrix1[i][k] * matrix2[k][j]; + result[j][k] += matrix1[i][j] * matrix2[k][j]; } } } diff --git a/README.md b/README.md new file mode 100644 index 0000000..3839353 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# SourceCodeTest +Example For Github Testing + +Students should clone this code and make changes to it using their Visual Studio Code debugger. From 8383e56c206ed759876485bd959faacb266aed84 Mon Sep 17 00:00:00 2001 From: aidanrahill <116307633+aidanrahill@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:34:21 -0700 Subject: [PATCH 2/2] fixed --- MatrixExample.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MatrixExample.java b/MatrixExample.java index 051e5bc..a1ceb63 100644 --- a/MatrixExample.java +++ b/MatrixExample.java @@ -20,7 +20,7 @@ public static void main(String[] args) { System.out.println("result length: " + result.length + " x " + result[0].length); for (int i = 0; i < result.length; i++) { - for (int j = 0; j < result[i].length; i++) { + for (int j = 0; j < result[i].length; j++) { System.out.print(result[i][j] + " "); } System.out.println(); @@ -40,13 +40,13 @@ public static int[][] multiplyMatrices(int[][] matrix1, int[][] matrix2) { } // Some more issues here too - int[][] result = new int[rows1+1][cols2+1]; + int[][] result = new int[rows1][cols2]; // Lots of issues with this code, it used to be working perfectly though for (int i = 0; i < rows1; i++) { for (int j = 0; j < cols2; j++) { for (int k = 0; k < cols1; k++) { - result[j][k] += matrix1[i][j] * matrix2[k][j]; + result[i][j] += matrix1[i][k] * matrix2[k][j]; } } }