运用STL快速得到枚举排列

来源:互联网 发布:软件工程项目总监职责 编辑:程序博客网 时间:2024/06/03 21:45

输入一个字符串,要求输出字符串中所有字符的排列?

运用STL快速得到枚举排列。

#include<iostream>#include<string>#include<algorithm>using namespace std;int main(){    string s;    while(cin>>s)    {        sort(s.begin(),s.end());        do        {            cout<<s<<' ';        }while(next_permutation(s.begin(),s.end()));        cout<<endl;    }    return 0;}



0 0
原创粉丝点击