字符串全排列代码
来源:互联网 发布:python爬虫高级教程 编辑:程序博客网 时间:2024/06/10 04:38
Permutation(char a[], int start, int end)
{
int i;
char temp;
if(start == end)
{
for(i = 0; i <= end; i++)
printf(" %c ",a[i]);
printf("/n");
}
else
{
for(i = start; i <= end; i++)
{
temp=a[start]; a[start]=a[i]; a[i]=temp;
Permutation(a, start+1, end);
temp=a[start]; a[start]=a[i]; a[i]=temp;
}
}
}
第二种:
void Permutation(char* pStr, char* pBegin)
{
if(!pStr || !pBegin)
return;
// if pBegin points to the end of string,
// this round of permutation is finished,
// print the permuted string
if(*pBegin == '/0')
{
printf("%s/n", pStr);
}
// otherwise, permute string
else
{
for(char* pCh = pBegin; *pCh != '/0'; ++ pCh)
{
// swap pCh and pBegin
char temp = *pCh;
*pCh = *pBegin;
*pBegin = temp;
Permutation(pStr, pBegin + 1);
// restore pCh and pBegin
PS:改变字符串顺序后必须还原回来!
temp = *pCh;
*pCh = *pBegin;
*pBegin = temp;
}
}
}
- 字符串全排列代码
- 字符串全排列代码实现
- 字符串全排列的C++实现代码
- 5、字符串全排列--Java代码
- 字符串的全排列
- 字符串的全排列
- 字符串全排列问题
- 字符串全排列
- 字符串全排列问题
- 字符串全排列
- 求字符串全排列
- 求字符串全排列
- 字符串的全排列
- 字符串全排列
- 字符串全排列
- 字符串全排列
- 字符串的全排列
- 字符串全排列
- 不太明白的调用。
- WEB安全测试通常要考虑的测试点
- 解析Unicode编码和Java char(转自Oilamp的163博客)
- wince控制面板如何添加应用程序
- JAVA中的JNI
- 字符串全排列代码
- Eclipse导入工程
- Oracle日期函数dayadd/datediff/datepart
- html 去掉图片链接的边框
- 【转】版本控制軟體hg (Mercurial)
- Zend_File_Transfer文件上传
- 浅谈C++中的LPVOID类型
- jetty 1.6 嵌入使用webapps
- MFC之对话框