next-permutation与prev-permutation
来源:互联网 发布:淘宝手办黑店曝光 编辑:程序博客网 时间:2024/04/28 04:09
记录下顺序全排列与逆序全排列的stl函数运用方法,只记录用法,不再写俩函数实现具体过程,毕竟我不会QAQ
#include<iostream>#include<algorithm>using namespace std;int cmp(int a,int b){ return a>b?1:0;}int main(void){ int n,p[100],cur=0; cin>>n; for(int i=0;i<n;++i) cin>>p[i]; sort(p,p+n,cmp); do{ //prev_permutation()先进行从大到小的排序 for(int i=0;i<n;i++) cout<<p[i]<<" "; cout<<endl; } while(prev_permutation(p,p+n)); //next_permutation()需要对数组先进行从小到大排序才能打印出全排列 /*do{ for(int i=0;i<n;i++) cout<<p[i]<<" "; cout<<endl; } while(next_permutation(p,p+n)); */ return 0;}
0 0
- next-permutation与prev-permutation
- Permutation, next Permutation, Permutation sequence
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- Next Permutation
- js中CheckBox选择框选择选中之前的选择框
- 动态网页与静态网页区别以及各自的优缺点
- B/S技术
- Kafka三款监控工具比较
- Calling startActivity() from outside of an Activity错误
- next-permutation与prev-permutation
- Leetcode 62. Unique Paths
- html基本结构
- Windows Bat脚本Sleep, loop, if/else
- Android布局: fill_parent、wrap_content和match_parent的区别
- MyEclipse 10中SVN的安装
- git提交命令代码
- GOF设计模式--简单工厂模式
- 启动tomcat7w.exe是提示未安装指定服务