文章

227

粉丝

0

获赞

962

访问

36.5k

头像
全排列 题解:

#include<iostream>
using namespace std;

const int N=10;

bool path[N];
string str;
char s[N];

void dfs(int u)
{
	if(u==str.size())
	{
		cout<<s<<endl;
		return;
	}
	for(int i=0;i<str.size();i++)
	{
		if(!path[i])
		{
			s[u]=str[i];
			path[i]=true;
			dfs(u+1);
			path[i]=false;
		}
	}
}


int main()
{
	cin>>str;
	dfs(0);
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发