#include "iostream"
using namespace std;
void permu(char * pStr, char * pBegin)
{
if (*pBegin == '\0')
{
printf("%s\n",pStr);
}
else
{
for (char *pCh = pBegin; *pCh != '\0'; pCh++)
{
char temp = *pCh;
*pCh = *pBegin;
*pBegin = temp;
permu(pStr , pBegin+1);
temp = *pCh;
*pCh = *pBegin;
*pBegin = temp;
}
}
}
void p(char *pStr)
{
if (NULL == pStr)
{
return;
}
permu(pStr,pStr);
}
void main(void)
{
char s[5] = {"abc"};
p(s);
getchar();
}
abc 的全排列
abc
acb
bac
bca
cab
cba