public static void showArr(int index1,int index2,int index3,int index4,int index5) {
int[] arr1 = {1,2,3,4,5};
int[] arr2 = cutArr(arr1,arr1[index1]);
int[] arr3 = cutArr(arr2,arr2[index2]);
int[] arr4 = cutArr(arr3,arr3[index3]);
int[] arr5 = cutArr(arr4,arr4[index4]);
System.out.println(arr1[index1]+""+arr2[index2]+""+arr3[index3]+""+arr4[index4]+""+arr5[index5]);
index5++;
if (index5 == arr5.length) {
index4++;
index5 = 0;
if (index4 == arr4.length) {
index3++;
index4 = 0;
if (index3 == arr3.length) {
index2++;
index3 = 0;
if (index2 == arr2.length) {
index1++;
index2 = 0;
if (index1 == arr1.length) {
return;
}
}
}
}
}
showArr(index1,index2,index3,index4,index5);
}
public static int[] cutArr(int[] arr,int x) {
int[] targetArr = new int[arr.length-1];
for (int index = 0;index<arr.length;index++) {
if (arr[index] == x) {
int i = 0;
for (;i<targetArr.length;i++) {
if (arr[i] != x) {
targetArr[i] = arr[i];
}else {
break;
}
}
for (int j = i;j<targetArr.length;j++) {
targetArr[j] = arr[j+1];
}
}
}
return targetArr;
} |
|