class subfunctionApp1{
static String[] permutationCurrent;
static String[] permutationPrivious;
static String permutation;
static char[] permutationCurrentChar;
public static void main(String[]args){
String[] arr ;
arr =subfunction(2);
for(int i = 0;i<arr.length;i++){
System.out.print(arr+" ");}
}
public static String[] subfunction(int k){
int l,i,j;
int time = -1;
if(k>1){
permutationCurrent = new String[k*(k-1)];
for(l = 0;l<=(k-2)*(k-1);l++){
permutationCurrentChar = new char[k];
permutationPrivious = subfunction(k-1);
char[] array=permutationPrivious[l].toCharArray();
for(i = 0;i<array.length;i++){
permutationCurrentChar = array;}
for(i = 0;i<=k-1;i++){
if(i<(k-1)){
for(j = k-1;j>i;j--){
permutationCurrentChar[j] = permutationCurrentChar[j-1];}}
permutationCurrentChar = (char)2;
permutation = new String(permutationCurrentChar);
System.out.println(permutation);
permutationCurrent[++time] = permutation;}}}
else if(k==1){
permutationCurrent = new String[k];
permutationCurrent[0] ="1"; }
return permutationCurrent;}
}
//总是返回空,神烦,希望大神帮我。
|