25,980
社区成员
发帖
与我相关
我的任务
分享
package com;
import java.util.ArrayList;
import java.util.List;
public class Test {
public static String[] globalSt = {"1","2","3"};
public static List<String> tempList = new ArrayList<String>();
public static List<String> resulList = new ArrayList<String>();
public static void main(String[] args) {
for(int u=0;u<globalSt.length;u++){
resulList.add(globalSt[u]);
}
round(globalSt.length);
System.out.println("============");
for(int i=0;i<resulList.size();i++){
System.out.println(resulList.get(i));
}
}
public static void round(int iRound){
if(iRound == 1)
return ;
tempList = new ArrayList<String>();
for(int i=0; i<resulList.size(); i++){
String st = resulList.get(i);
for(int j=0;j<globalSt.length;j++){ //只要没出现过的,都可以放进去
if(st.indexOf(globalSt[j])<0){//没有
String newSt = st + globalSt[j];
tempList.add(newSt);
}
}
}
resulList = tempList;
for(int i=0;i<resulList.size();i++){
System.out.println(resulList.get(i));
}
round( iRound -1);
}
}