全排列
输入一些字符,然后程序会列出出这些字符全部用上的所有组合,这就是全排列
但是如果输入的字符为a、a、b这样,含有重复字符的话,则会出现重复的结果,这需要在程序中去重。
将每个字符看作积木,字符的排列看作将积木放入插槽中。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int counter;
int occurrenceCheck(int length, char* source, int targetPlace, char targetChar)
// 这个函数返回了source串中,targetPlace之前,targetChar字符的出现次数
// 返回-1代表错误
{
if (targetPlace >= length)
{
return -1;
}
int occurrenceCounter = 0;
for (int i = 0; i < targetPlace; i++)
{
if (source[i] == targetChar)
{
occurrenceCounter++;
}
}
return occurrenceCounter;
}
void findThem(int totalLength, char* source, int placeToBeFilled, char* usageDictionary, char* currentSlot, char* sourceOccurrence)
// placeToBeFilled代表即将会被放入一个字符的空插槽的序号</