早教吧 育儿知识 作业答案 考试题库 百科 知识分享

求教算法,用程序写出来,什么语言都可以集合A(abcdefgklm)集合B(qwertyuiop)求两个集合元素的所有组合,不能重复例如(aq,qw,ae,)例如(aq,aw,ae.)上面写错了

题目详情
求教算法,用程序写出来,什么语言都可以
集合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();
}
}
看了 求教算法,用程序写出来,什么...的网友还看了以下: