diff --git a/MatrixExample.java b/MatrixExample.java index 051e5bc..428b9e7 100644 --- a/MatrixExample.java +++ b/MatrixExample.java @@ -1,32 +1,5 @@ import java.util.Random; - public class MatrixExample { - public static void main(String[] args) { - int[][] matrix = { - { 1, 2, 3, 4, 5, 6 }, - { 4, 5, 6, 3, 7, 2 }, - { 27, 8, 9, 5, 3, 21 }, - { 73, 2, 19, 5, 1, 8 }, - { 47, 9, 9, 5, 0, 22 }, - { 78, 86, 1, 4, 1, 21 }, - { 73, 18, 2, 2, 5, 11 } - }; - - int numRows = 6; - int numCols = 7; - - int[][] matrix2 = generateRandomMatrix(numRows, numCols); - int[][] result = multiplyMatrices(matrix, matrix2); - - 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++) { - System.out.print(result[i][j] + " "); - } - System.out.println(); - } - - } public static int[][] multiplyMatrices(int[][] matrix1, int[][] matrix2) { int rows1 = matrix1.length; diff --git a/MatrixExampleTester.java b/MatrixExampleTester.java new file mode 100644 index 0000000..3fb591c --- /dev/null +++ b/MatrixExampleTester.java @@ -0,0 +1,28 @@ +public class MatrixExampleTester { + public static void main(String[] args) { + int[][] matrix = { + { 1, 2, 3, 4, 5, 6 }, + { 4, 5, 6, 3, 7, 2 }, + { 27, 8, 9, 5, 3, 21 }, + { 73, 2, 19, 5, 1, 8 }, + { 47, 9, 9, 5, 0, 22 }, + { 78, 86, 1, 4, 1, 21 }, + { 73, 18, 2, 2, 5, 11 } + }; + + int numRows = 6; + int numCols = 7; + + int[][] matrix2 = generateRandomMatrix(numRows, numCols); + int[][] result = multiplyMatrices(matrix, matrix2); + + 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++) { + System.out.print(result[i][j] + " "); + } + System.out.println(); + } + + } +}