/**
* @(#)Permutation.java
*
*
* @author
* @version 1.00 2008/10/22
*/
package javaTest;
import java.util.Scanner;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Permutation {
/**
* Creates a new instance of <code>Permutation</code>.
*/
public static void swap(Object[]a,int i,int j)
{
Object temp=a[i];
a[i]=a[j];
a[j]=temp;
}
public static void Permutation(Object[]list,int k,int m) {
if(k==m)
{for(int i=0;i<=m;i++)
System.out.print(list[i]);
System.out.println();
}
else
for(int i=k;i<=m;i++)
{
swap(list,k,i);
Permutation(list,k+1,m);
swap(list,k,i);
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int n=0,m=0;
Object list[];
Scanner scan=new Scanner(System.in);
System.out.print("input n=");
n=scan.nextInt();
list=new Object[n];
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<n;i++)
{
try {
System.out.print("请输入第"+(i+1)+"个数:");
list[i]=Integer.parseInt(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
Permutation(list,0,n-1);
}
}