1048 -- 求某一整数序列的全排列问题

来源:互联网 发布:js压缩 tomcat 编辑:程序博客网 时间:2024/06/05 20:14

求某一整数序列的全排列问题

Time Limit:1000MS  Memory Limit:65536K
Total Submit:45 Accepted:20

Description

现有一整数序列如:123,请计算出它的全排列。

Input

输入数据有两行组成,第一行为整数序列的长度,第二行为整数序列,序列元素之间以Tab符相隔。

Output

输出数据为整数序列的全排列,每一个排列单独占一行。

Sample Input

31 2 3

Sample Output

123132213231312321

Source

/* * http://183.167.205.82:8081/JudgeOnline/showproblem?problem_id=1048 * by jtahstu on 2015/2/7 7:00 * 知识点: 排列生成器     按字典序的下一个排列     next_permutation() *                         按字典序的前一个排列     prev_permutation() */#include<iostream>#include<algorithm>#include<string>using namespace std;int main() {    int m;    string s,a;    cin>>m;    for(int i=0; i<m; i++) {        cin>>a;        s+=a;    }    cout<<s<<endl;    while(next_permutation(s.begin(),s.end()))        cout<<s<<endl;    return 0;}


0 0
原创粉丝点击