优先队列 next_permutation
来源:互联网 发布:mac os x10.9 iso下载 编辑:程序博客网 时间:2024/05/18 20:35
这是我写的2个测试程序
优先队列
#include<stdio.h>#include<queue>#include<algorithm>using namespace std;struct node{ int x,y; friend bool operator<(const node a,const node b) { return a.x>b.x||(a.x==b.x&&a.y>b.y); //>按从小到大排,<按从大到小排 }};node p[30];int main(){ int n; while(scanf("%d",&n)==1) { int i; priority_queue<node> q; for(i=0;i<n;i++) { scanf("%d%d",&p[i].x,&p[i].y); q.push(p[i]); } while(!q.empty()) { node tmp=q.top(); q.pop(); printf("(%d,%d)\n",tmp.x,tmp.y); } } return 0;}
next_permutation
#include<stdio.h>#include<algorithm>using namespace std;int main(){ int n,p[10]; while(scanf("%d",&n)==1) { for(int i=0;i<n;i++) scanf("%d",&p[i]); sort(p,p+n); do { for(int i=0;i<n;i++) printf("%d ",p[i]); printf("\n"); }while(next_permutation(p,p+n)); } return 0;}
- 优先队列 next_permutation
- hdu1716排列2(stl:next_permutation+优先队列)
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- CMake的使用
- Jsp隐式对象 和 EL隐式对象
- UML读书笔记(2)类图
- 每个人都有自己的“七寸”
- 虚拟化的逆袭:网络虚拟化之OpenFlow和SDN
- 优先队列 next_permutation
- 具体条码扫描技术和RFID射频读卡技术Andriod工业平板电脑
- spring的ContextLoaderListener
- ubuntu下mysql的常用命令
- C#判断是否属于字母类别
- 搜索引擎是如何认定锚文本连接的时效性
- 天书般的ICTCLAS分词系统代码(二)
- 3D模型动画
- ewebeditor在线编辑器IE8下 按钮没反应的解决方法