将两个数组 排列组合到一个数组集合 求java 代码输入 数组1{a,b,c} 数组2{x,y,z}输出List数组 {a,b,c} 去掉 C3/3 C0/3 排列组合 {a} {b} {c} {a,b} {a,c} {b,c}{x,y,z} 去掉 C3/3 C0/3 排列组合 {x} {y} {z} {x,y} {x,z} {y

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/08 11:56:25
将两个数组 排列组合到一个数组集合 求java 代码输入 数组1{a,b,c} 数组2{x,y,z}输出List数组 {a,b,c} 去掉 C3/3  C0/3 排列组合 {a} {b} {c} {a,b} {a,c} {b,c}{x,y,z} 去掉 C3/3  C0/3 排列组合 {x} {y} {z} {x,y} {x,z} {y

将两个数组 排列组合到一个数组集合 求java 代码输入 数组1{a,b,c} 数组2{x,y,z}输出List数组 {a,b,c} 去掉 C3/3 C0/3 排列组合 {a} {b} {c} {a,b} {a,c} {b,c}{x,y,z} 去掉 C3/3 C0/3 排列组合 {x} {y} {z} {x,y} {x,z} {y
将两个数组 排列组合到一个数组集合 求java 代码

输入 数组1{a,b,c} 数组2{x,y,z}
输出List数组 

{a,b,c} 去掉 C3/3  C0/3 排列组合 {a} {b} {c} {a,b} {a,c} {b,c}
{x,y,z} 去掉 C3/3  C0/3 排列组合 {x} {y} {z} {x,y} {x,z} {y,z}

现在要求当 数组1{a,b,c} 取a 的时候 从数组二中取{y,z}  组合成 {a,y,z} 
现在要求当 数组1{a,b,c} 取b 的时候 从数组二中取{x,z}  组合成 {x,b,z} 
现在要求当 数组1{a,b,c} 取c 的时候 从数组二中取{x,z}  组合成 {x,y,c} 

依次类推
现在要求当 数组1{a,b,c} 取{a,b} 的时候 从数组二中取{z}  组合成 {a,b,z}
.

输出的List   List数组就是组合的数组.

( 从数组1从取数据填充到新的数组对应的位子,其他位置由对应的数组2中取.)

将两个数组 排列组合到一个数组集合 求java 代码输入 数组1{a,b,c} 数组2{x,y,z}输出List数组 {a,b,c} 去掉 C3/3 C0/3 排列组合 {a} {b} {c} {a,b} {a,c} {b,c}{x,y,z} 去掉 C3/3 C0/3 排列组合 {x} {y} {z} {x,y} {x,z} {y
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Test {
private String[] arr1;
private String[] arr2;

public Test(){
//数组长度可以随意改,但必须保证两个数组长度一样
arr1 = new String[3];
arr2 = new String[3];
initArray();
}

private void initArray(){
Scanner scanner = new Scanner(System.in);
for(int i=0;i