package permutation;
import java.util.Scanner;
public class AscendPermutation {
// get initialization permutation of scale is number
public String creatPermutation(int number) {
char[] ch = new char[number];
for (int i = 1; i <= number; ++i)
ch[i - 1] = (char) (i + 48);
return String.valueOf(ch);
}
// get interNumber 0f original permutation number
public String getInterNumber(String permutation) {
char[] ch = permutation.toCharArray();
char[] save = new char[permutation.length() - 1];
// form 2 to str.length() need to search
for (int i = 0; i < permutation.length(); ++i) {
if (ch[i] == '1')
continue;
// find the quantity of digit which right i is smaller than i
// save is char type so make count = 48 initialization
int j = i + 1, count = 48;
while (j < permutation.length()) {
if (ch[i] > ch[j]) {
++cou
全排列-递增进位制数法
最新推荐文章于 2023-02-11 17:50:59 发布