28.字符串的排列


void Permutation(char*  pStr)
{
if (pStr == NULL)
return;
Permutation(pStr, pStr);
}
void Permutation(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;
Permutation(pStr, pBegin + 1);
temp = *pCh;
*pCh = *pBegin;
*pBegin = temp;
}
}
}











posted @ 2017-04-26 12:05  wzjhoutai  阅读(103)  评论(0编辑  收藏  举报