1. 首页
  2. 数据库
  3. 其它
  4. next_permutation和prev_permutation两个STL自带排列函数

next_permutation和prev_permutation两个STL自带排列函数

上传者: 2021-01-16 12:32:47上传 PDF文件 28.99KB 热度 11次
事先说明: 需要引入头文件#include 排序是按字典序排序,当然也可以自定义排序 函数是返回当前排列的下一个排列,如果没有,返回false 这两种方法都用永久性的改变了容器中元素的位置 排列的对象可以是任意的,基本数据类型、字符串、结构体等 一:next_permutation(start,end,//cmp) 使用默认排序方法:按照字典序从小到大 int arr[3]={1,2,3}; do{ for(int num:arr){ cout<<num<< ; } cout<<endl; }while(next_pe
下载地址
用户评论