我发布了这个,尽管已经有很多关于这个问题的帖子.我不想发布作为答案,因为它不起作用.这篇文章的答案(找到所有可能的重复排列列表中的给定字符串的排名)对我来说不起作用.
所以我尝试了这个(这是我抄袭的代码汇编和我处理重复的尝试).非重复案件工作正常.BOOKKEEPER生成83863,而不是所需的10743.
(阶乘函数和字母计数器数组'重复'工作正常.我没有发帖以节省空间.)
while (pointer != length)
{
if (sortedWordChars[pointer] != wordArray[pointer])
{
// Swap the current character with the one after that
char temp = sortedWordChars[pointer];
sortedWordChars[pointer] = sortedWordChars[next];
sortedWordChars[next] = temp;
next++;
//For each position check how many characters left have duplicates,
//and use the logic that if you need to permute n things and if 'a' things
//are similar the number of permutations is n!/a!
int ct = repeats[(sortedWordChars[pointer]-64)];
// Increment the rank
if (ct>1) …Run Code Online (Sandbox Code Playgroud)