From 8bb6e8f4975ca94600c85ba93dcaa964c01ec872 Mon Sep 17 00:00:00 2001 From: WINDOWS 10 Date: Sun, 2 Dec 2018 21:27:32 +0700 Subject: [PATCH 1/2] MatrixMaxFinder by Burhan Ilham Haqiqi --- .../utils/matrix/operators/MatrixMaxFinder.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java b/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java index 607c54e..9488ab7 100644 --- a/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java +++ b/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java @@ -7,4 +7,17 @@ // [8, 5, 3]] // Output: 8 public class MatrixMaxFinder implements MatrixReducer { + int [][]input ={{3, 1, 7}, + {5, 2, 2}, + {8, 5, 3}}; + int max = Integer.MIN_VALUE; + for (int i = 0; i < input.length; i++) { + for (int j = 0; j < input.length; j++) { + if (in[i][j]>max) { + max=in[i][j]; + } + } + } + System.out.println("Output : "+max); + } From 77cf7c513dd61b50c783f8de93f288e81249572c Mon Sep 17 00:00:00 2001 From: WINDOWS 10 Date: Wed, 5 Dec 2018 20:22:01 +0700 Subject: [PATCH 2/2] MatrixMaxFinder by Burhan Ilham Haqiqi --- .../matrix/operators/MatrixMaxFinder.java | 58 ++++++++++++++++--- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java b/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java index 9488ab7..38f4729 100644 --- a/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java +++ b/JavaUtils/src/id/ac/ub/filkom/rendicahya/utils/matrix/operators/MatrixMaxFinder.java @@ -7,17 +7,57 @@ // [8, 5, 3]] // Output: 8 public class MatrixMaxFinder implements MatrixReducer { - int [][]input ={{3, 1, 7}, - {5, 2, 2}, - {8, 5, 3}}; - int max = Integer.MIN_VALUE; - for (int i = 0; i < input.length; i++) { - for (int j = 0; j < input.length; j++) { - if (in[i][j]>max) { - max=in[i][j]; + + + public static int max(int[][]input) { + + int max = Integer.MIN_VALUE; + for (int i = 0; i < input.length; i++) { + for (int j = 0; j < input.length; j++) { + if (input[i][j] > max) { + max = input[i][j]; + } } } + return max; + } + + public static void main(String[] args) { + int[][] input = {{3, 1, 7}, + {5, 2, 2}, + {8, 5, 3}}; + + System.out.println("Output: "+max(input)); + } + + @Override + public byte reduce(byte[][] input) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public short reduce(short[][] input) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public int reduce(int[][] input) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public long reduce(long[][] input) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public float reduce(float[][] input) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - System.out.println("Output : "+max); + @Override + public double reduce(double[][] input) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + }