排列组合与八皇后问题(Python版本)
发布时间
阅读量:
阅读量
全排列的递归解法法一
#include <iostream>
#include <cstdio>
using namespace std;
void swap_alpha(char *a,char *b)
{
char temp=*a;
*a=*b;
*b=temp;
return;
}
void main_function(char *str,char *pbegin)
{
if(*pbegin=='\0')
{
printf("%s\n",str); //注意str和pbegin指向同一块内存
return;
}
for(char *ch=pbegin;*ch!='\0';ch++)
{
swap_alpha(ch,pbegin);
main_function(str,pbegin+1);
swa
全部评论 (0)
还没有任何评论哟~
