import java.util.*; class Kombinacje { static double[][] input = {{1.2,2.0,5.0,5.1},{13.13},{2.0,4.0,5.0},{1.3,2.0},{8.8}}; { int howMany = 1; for(int i=0;i<input.length;i++) { howMany*=input[i].length; } ArrayList<ArrayList<Double>> result = new ArrayList<ArrayList<Double>>(); for(int i=0;i<input[0].length;i++) { ArrayList<Double> al = new ArrayList<Double>(); al.add(input[0][i]); result.add(al); } for(int i=1;i<input.length;i++) { result = append(result,i); } for(int w=0;w<result.size();w++) { } } private static ArrayList<ArrayList<Double>> append(ArrayList<ArrayList<Double>> old,int pos) { ArrayList<ArrayList<Double>> result = new ArrayList<ArrayList<Double>>(); for(ArrayList<Double> list:old) { for(int i=0;i<input[pos].length;i++) { ArrayList<Double> al = new ArrayList<Double>(); al.addAll(list); al.add(input[pos][i]); result.add(al); } } return result; } }
Standard input is empty
24 [1.2, 13.13, 2.0, 1.3, 8.8] [1.2, 13.13, 2.0, 2.0, 8.8] [1.2, 13.13, 4.0, 1.3, 8.8] [1.2, 13.13, 4.0, 2.0, 8.8] [1.2, 13.13, 5.0, 1.3, 8.8] [1.2, 13.13, 5.0, 2.0, 8.8] [2.0, 13.13, 2.0, 1.3, 8.8] [2.0, 13.13, 2.0, 2.0, 8.8] [2.0, 13.13, 4.0, 1.3, 8.8] [2.0, 13.13, 4.0, 2.0, 8.8] [2.0, 13.13, 5.0, 1.3, 8.8] [2.0, 13.13, 5.0, 2.0, 8.8] [5.0, 13.13, 2.0, 1.3, 8.8] [5.0, 13.13, 2.0, 2.0, 8.8] [5.0, 13.13, 4.0, 1.3, 8.8] [5.0, 13.13, 4.0, 2.0, 8.8] [5.0, 13.13, 5.0, 1.3, 8.8] [5.0, 13.13, 5.0, 2.0, 8.8] [5.1, 13.13, 2.0, 1.3, 8.8] [5.1, 13.13, 2.0, 2.0, 8.8] [5.1, 13.13, 4.0, 1.3, 8.8] [5.1, 13.13, 4.0, 2.0, 8.8] [5.1, 13.13, 5.0, 1.3, 8.8] [5.1, 13.13, 5.0, 2.0, 8.8]