public class Order2 {
static int num=1;
private boolean isIn(int a[],int start,int num){
for(int i=0;i<start;i++){
if(a[i]==num)
return true;
}
return false;
}
public void orderNumber(int[] a, int start, int deep, int length, int k) {
int passNum[]=new int[length];
int passLength=0;
for (int i = start; i < length; i++) {
if(isIn(passNum,passLength,a[i]))
continue;
passNum[passLength]=new Integer(a[i]).intValue();
passLength++;
int t = a[start];
a[start] = a[i];
a[i] = t;
if (deep == 1) {
System.out.print(num+++" ");
for (int j = 0; j < k; j++)
System.out.print(a[j]);
System.out.println();
} else
orderNumber(a, start + 1, deep - 1, length, k);
t = a[start];
a[start] = a[i];
a[i] = t;
}
}
public static void main(String arg[]){
int a[]={1,2,2,4,5};
int start=0;
int deep=3;
int length=5;
new Order2().orderNumber(a, start, deep, length,deep);
}
}