方法1:
#include <stdio.h>#include <stdlib.h>
void Permutation(char a[], int start, int end)
{
int i,j;
char temp;
if(start == end)
{
for(i = 0; i <= end; i++)
printf(" %c ",a[i]);
printf("\n");
}
else
{
for(i = start; i <= end; i++)
{
for(j=start;j<i;j++)
if(a[j]==a[i]) goto nextI;
temp=a[start]; a[start]=a[i]; a[i]=temp;
Permutation(a, start+1, end);
temp=a[start]; a[start]=a[i]; a[i]=temp;
nextI:;
}
}
}
int main()
{
char A[] = "abcc";
Permutation(A,0,3);
system("pause");
return 0;
}
本文介绍了一种使用递归方法生成给定字符数组的所有全排列的算法实现。通过示例代码演示了如何在C语言环境下实现这一功能。
&spm=1001.2101.3001.5002&articleId=7424308&d=1&t=3&u=15d42a4a78b44e869fb3fddc45a2f466)
3604

被折叠的 条评论
为什么被折叠?



