首页 > 其他 > 详细

51Nod 1384 全排列

时间:2018-10-09 00:19:58      阅读:159      评论:0      收藏:0      [点我收藏+]

STL的应用。想到全排列就想到了STL中的 next_permutation() 函数。用字符串读取输入,用 sort() 对其进行排序,再用 next_permutation() 输出结果。代码如下:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
#define ll long long
#define ull_ unsigned long long

using namespace std ;

int main(){
    string str ;
    cin >> str ;
    sort(str.begin() , str.end()) ;
    cout << str << endl ;
    while(next_permutation(str.begin() , str.end())){
        for ( int i = 0 ; i < str.size() ; i ++ ){
            cout << str[i] ;
        }
        cout << endl ;
    }
    return 0 ;
}

51Nod 1384 全排列

原文:https://www.cnblogs.com/Cantredo/p/9757964.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!