洛谷 1691 有重复元素的排列问题

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n,m;
    scanf("%d",&m);
    string ch;
    cin >> ch;
    sort(ch.begin(),ch.end());
    n=0;
    do
    {
        cout << ch <<endl;
        n++;
    }while(next_permutation(ch.begin(),ch.end()));
    cout <<n;
    return 0;
}

"next_permutation" is very cool 

猜你喜欢

转载自blog.csdn.net/wyh1618/article/details/80298517