作业帮 > 综合 > 作业

求教算法,用程序写出来,什么语言都可以

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/06/08 03:36:01
求教算法,用程序写出来,什么语言都可以
集合A(a b c d e f g k l m)
集合B(q w e r t y u i o p)
求两个集合元素的所有组合,不能重复
例如(aq,qw,ae,)
例如(aq,aw,ae.)上面写错了
public static void main(String[] arg){
String[] arg1 ={"a","b","c","d","e","f","g","k","l","m"};
String[] arg2 ={"q","w","e","r","t","y","u","i","o","p"};
for (int i = 0; i < arg1.length; i++) {
System.out.print(arg1[i]);
for (int j = 0; j < arg2.length; j++) {
System.out.print(arg2[j]);
}
System.out.println();
}
}