蓝桥杯—next_permutation()全排列函数

/*
输出字符串的全排列
*/
#include 
#include 
#include 

using namespace std;

int main()
{
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    cout << str << endl;
    while (next_permutation(str.begin(), str.end()))
    {
        cout << str << endl;
    }
    return 0;
}
运行结果:

蓝桥杯—next_permutation()全排列函数_第1张图片

/*
实现数组int型全排列
*/
#include 
#include 
#include 
#include 
using namespace std;
int main()
{
    int a[100],i,n;
    scanf("%d",&n);
    for (i=0; i

运行结果:

蓝桥杯—next_permutation()全排列函数_第2张图片

你可能感兴趣的:(蓝桥杯)