package permutation;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("---------------start-------------");
Scanner scan = new Scanner(System.in);
System.out.println("Please choose type of permutation:");
System.out.println("0: ascend permutation,\t1: decline permutation,"
+ "\n2: neighbour exchange permutation, default: dictionary permutation :");
int choose = scan.nextInt();
long start = System.currentTimeMillis();
while(choose>=0){
System.out.println("Please input the scale of permutation: ");
int scale = scan.nextInt();
switch(choose){
case 0 :
System.out.println("ascend permutation:");
AscendPermutation ap = new AscendPermutation();
ap.ascendPermutationAlgorathim(ap.creatPermutation(scale));
break;
case 1 :
System.out.println("decline permutation:");
DeclinePermutation dp = new DeclinePermutation ();
dp.declinePermutationAlgorathim(dp.creatPermutation(scale));
break;
case 2 :
System.out.println("neighbour exchange permutation:");
NeighbourExchangePermutation nep = new NeighbourExchangePermutation();
nep.neighbourExchangePermutation(nep.creatPermutation(scale));
break;
default :
System.out.println("dictionary permutation:");
DictionaryPermutation dictp = new DictionaryPermutation();
dictp.permutation(dictp.creatPermutation(scale));
}
long end = System.currentTimeMillis();
// System.out.println("run time : " + (double)Math.round((end - start)/1000) + " Second ");
System.out.println("run time : " + (end - start) + " MillionSecond ");
System.out.println("---------------end---------------\n\n");
System.out.println("---------------start-------------");
choose = scan.nextInt();
start = System.currentTimeMillis();
}
System.out.println("---------------end---------------");
}
}
测试四种全排列
最新推荐文章于 2023-07-11 19:28:03 发布