日期:2014-05-20 浏览次数:20697 次
public static void main(String[] args){
int[] a = {1,2,3};
String[] s = {"a","b","c"};
List<StringBuilder> builders = new ArrayList<StringBuilder>();
for(int i=0;i<a.length;i++){
if(builders.size() <=0){
builders.add(new StringBuilder().append(a[i]));
builders.add(new StringBuilder().append(s[i]));
}else{
int k = builders.size();
for(int j=0;j<k;j++){
builders.add(new StringBuilder().append(builders.get(j)).append(s[i]));
builders.get(j).append(a[i]);
}
}
}
for(int i=0;i<builders.size();i++){
System.out.println(builders.get(i).toString());
}
}
public static void main(String[] args){
String[] a = {"1","2","3"};
String[] b = {"a","b","c"};
for (int i=0;i<1<<a.length;i++){
String str = "";
for (int j=0;j<a.length;j++){
if ((i>>j&1)==0) str+=a[j];
else str+=b[j];
}
System.out.println(str);
}
}