字符串全排列
2016-09-08 17:28
169 查看
#include <iostream>
using namespace std;
void Permutation_o(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_o(pStr, pBegin+1);
//下面是最后一个步骤 你要把排乱的数组给放回去
temp = *pCh;
*pCh = *pBegin;
*pBegin = temp;
}
}
}
void Permutation_o(char* pStr)
{
if (pStr==NULL)
return;
Permutation_o(pStr,pStr);
}
int main(void)
{
char str[10]="abc";
Permutation_o(str);
//cout << str <<endl;
return 0;
}
using namespace std;
void Permutation_o(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_o(pStr, pBegin+1);
//下面是最后一个步骤 你要把排乱的数组给放回去
temp = *pCh;
*pCh = *pBegin;
*pBegin = temp;
}
}
}
void Permutation_o(char* pStr)
{
if (pStr==NULL)
return;
Permutation_o(pStr,pStr);
}
int main(void)
{
char str[10]="abc";
Permutation_o(str);
//cout << str <<endl;
return 0;
}
相关文章推荐
- 程序员面试100题之二十八,字符串的排列
- 剑指offer系列—T28字符串的排列
- java实现字符串排列组合问题
- 给定一个字符串,找出其所有不重复的排列组合
- 程序员面试100题之28字符串排列
- 字符串的排列
- ORACLE按字母顺序排列字符串
- 字符串的排列
- 【剑指Offer】字符串的排列
- Java排列组合字符串的方法
- 编写函数void change(char *a,char *b,char*c)。 函数功能是首先把b指向的字符串逆向存放 然后将a指向的字符串和b指向的字符串按排列顺序交叉合并到c指向的数
- 95 1.判断一字符串是不是对称 2.用递归的方法判断整数组 a[N]是不是升序排列
- 字符串全排列代码实现
- 字符串的倒序排列
- Morse Code HNUST 1675(字符串全排列 递归解决 数组a[]与流输入的缓慢)
- 剑指Offer_面试题28_字符串的排列
- 字符串的排列
- 字符串的排列组合问题
- 给定一个字符串,输出所有的排列组合方式
- 剑指offer--字符串的排列