二维表排列组合 //测试数组 String a[][] = {{"1", "2", "3"}, {"A", "B","C"},{"黑","白","灰"}}; int it = 1; for (int j = 0; j a.length; j++) { it *= a[j].length; } Set set= new HashSet(); while (it 0) { List tempList = new ArrayL
//测试数组 String a[][] = {{"1", "2", "3"}, {"A", "B","C"},{"黑","白","灰"}}; int it = 1; for (int j = 0; j < a.length; j++) { it *= a[j].length; } Setset= new HashSet<>(); while (it > 0) { List tempList = new ArrayList<>(); int temp = it; for (int m = 0; m < a.length; m++) { if (temp / a[m].length >= 0) { tempList.add(a[m][temp % a[m].length]); temp /= a[m].length; } } set.add(Arrays.toString(tempList.toArray())); System.out.println(Arrays.toString(tempList.toArray())); it--; } System.out.println(set.size());