码迷,mamicode.com
首页 > 编程语言 > 详细

全排函数c++ next_permutation()

时间:2020-05-31 16:17:28      阅读:67      评论:0      收藏:0      [点我收藏+]

标签:stream   c++   alt   tar   pre   include   style   pac   clu   

1.函数原型为:

     #include <algorithm>

     bool next_permutation(iterator start,iterator end)

2.用法

(1):需要将要数字按照升序排列

(2):使用方法:

#include<cstdio> 
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[3]={1,2,3};
    do{
        cout<<a[0]<<a[1]<<a[2]<<endl;
    }while(next_permutation(a,a+3));
    return 0;
}

运行结果:

技术图片

 

全排函数c++ next_permutation()

标签:stream   c++   alt   tar   pre   include   style   pac   clu   

原文地址:https://www.cnblogs.com/miao-xixixi/p/13018796.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!