Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.SortedSet;
- import java.util.TreeSet;
- public class Main {
- public static void main(String[] args) {
- double[][] c = { {1, 1, 2}, {3, 1, 3}, {1, 1, 1}, {4, 2, 1}};
- System.out.println("Before:");
- for (int i = 0; i < c.length; i++)
- System.out.println(Arrays.toString(c[i]));
- double[] max = new double[c[0].length];
- for (int i = 0; i < c[0].length; i++) {
- SortedSet<Double> element = new TreeSet<Double>();
- for (int j = 0; j < c.length; j++) {
- element.add(c[j][i]);
- }
- max[i] = element.last();
- }
- for (int i = 0; i < c.length; i++) {
- for (int j = 0; j < c[0].length; j++) {
- c[i][j] /= max[j];
- }
- }
- System.out.println("After:");
- for (int i = 0; i < c.length; i++)
- System.out.println(Arrays.toString(c[i]));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement