题解 | #全排列#

全排列

https://www.nowcoder.com/practice/5632c23d0d654aecbc9315d1720421c1

#include <bits/stdc++.h>
#define MAX 7
using namespace std;

vector<string> res;
void fun(char s[],string list){
	if(list.size() == strlen(s)){
		cout<<list<<endl;
		return ;
	}
	for(int i = 0; i < strlen(s); i++){
		if(list.find(s[i]) == string::npos)	//list中未加入此字符 
			fun(s,list+s[i]);
	}
		
}


int main(){
	char s[MAX];
	cin>>s;
	int len = strlen(s);
	string list;

	fun(s,list);

}

全部评论

相关推荐

点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务