fork download
  1. import java.util.*;
  2.  
  3. class Kombinacje
  4. {
  5. 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}};
  6. public static void main(String[] args)
  7. {
  8. int howMany = 1;
  9. for(int i=0;i<input.length;i++)
  10. {
  11. howMany*=input[i].length;
  12. }
  13. System.out.println(howMany);
  14. ArrayList<ArrayList<Double>> result = new ArrayList<ArrayList<Double>>();
  15. for(int i=0;i<input[0].length;i++)
  16. {
  17. ArrayList<Double> al = new ArrayList<Double>();
  18. al.add(input[0][i]);
  19. result.add(al);
  20. }
  21. for(int i=1;i<input.length;i++)
  22. {
  23. result = append(result,i);
  24. }
  25. for(int w=0;w<result.size();w++)
  26. {
  27. System.out.println(result.get(w));
  28. }
  29. }
  30. private static ArrayList<ArrayList<Double>> append(ArrayList<ArrayList<Double>> old,int pos)
  31. {
  32. ArrayList<ArrayList<Double>> result = new ArrayList<ArrayList<Double>>();
  33. for(ArrayList<Double> list:old)
  34. {
  35. for(int i=0;i<input[pos].length;i++)
  36. {
  37. ArrayList<Double> al = new ArrayList<Double>();
  38. al.addAll(list);
  39. al.add(input[pos][i]);
  40. result.add(al);
  41. }
  42. }
  43. return result;
  44. }
  45. }
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
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]