1750:全排列 —— next_permutation函数的使用

1750:全排列

#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	char s[10],src[10];
	int n;
	cin>>s;
	n=strlen(s);
	sort(s,s+n);
	strcpy_s(src,s);
	cout<<s<<endl;
	while(next_permutation(s,s+n))
	{
		if (strcmp(s,src)==0)
			break;
		else cout<<s<<endl;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/always_ease/article/details/80721026