#include<stdio.h>
#include<string.h>
void exchange(char *p,char *q)
{
if(*p!=*q)
{
*p=*p^*q;
*q=*p^*q;
*p=*p^*q;
}
}
void permutation(char *pstr,char *pbegin)
{
char *current;
if(*pbegin=='\0')
{
printf("%s\n",pstr);
}
else
{
for(current=pbegin;*current!='\0';current++)
{
exchange(pbegin,current);
permutation(pstr,pbegin+1);
exchange(pbegin,current);
}
}
}
void fullname(char *ptr)
{
if(ptr==NULL)
{
return ;
}
permutation(ptr,ptr);
}
int main(int argc,char *argv[])
{
char ptr[]="key";
fullname(ptr);
}
字符全排列
最新推荐文章于 2022-06-16 18:52:46 发布