当前位置 : 主页 > 编程语言 > java >

二维表排列组合

来源:互联网 收集:自由互联 发布时间:2021-06-28
二维表排列组合 //测试数组 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;
        }
        Set
 
   set= 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());
  
 
网友评论