博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++STL全排列
阅读量:4649 次
发布时间:2019-06-09

本文共 427 字,大约阅读时间需要 1 分钟。

包含在c++<algorithm>库中的next_permutation(arr,arr+n)函数可以实现arr中元素的全排列

但是要求arr中元素事先已经按字典序排列好

具体使用方法如下:

#include 
#include
using namespace std;int arr[5]={
1,3,2,3,4};int main(){ sort(arr,arr+5); while(next_permutation(arr,arr+5)) { for(int i=0;i<5;i++) { cout<
<<" "; } cout<

 

转载于:https://www.cnblogs.com/wsruning/p/5665616.html

你可能感兴趣的文章