#include "iostream"
using namespace std;
struct BinaryTreeNode{
int data;
BinaryTreeNode *left;
BinaryTreeNode *right;
};
void Permutation(char * pStr, char *pBegin)
{
if (*pBegin == '\0')
cout << pStr << endl;
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;
}
}
}
void Permutation(char * pStr)
{
if (pStr == NULL)
return;
Permutation(pStr, pStr);
}
int main()
{
char a[] = { "abc" };
Permutation(a);
system("pause");
return 0;
}
剑指offer面试题28:字符串的排列
最新推荐文章于 2024-06-02 17:21:27 发布