zoukankan      html  css  js  c++  java
  • 【stl】 优先队列小实验

     //被实验的代码君qwq
    //优先队列默认大根堆哟,greater可以重载小于号
    1
    #include<queue> 2 #include<cstdio> 3 #include<iostream> 4 using namespace std; 5 priority_queue<int, vector<int>, less<int> >q1; 6 priority_queue<int, vector<int>, greater<int> >q2; 7 priority_queue<int>q3; 8 int n; 9 int main() { 10 cin>>n; 11 int x; 12 for(int i = 1; i <= n; i++) { 13 cin>>x; 14 q1.push(x), q2.push(x), q3.push(x); 15 } 16 cout<<"less: "; 17 for(int i = 1; i <= n; i++) { 18 cout<<q1.top()<<' '; 19 q1.pop(); 20 } 21 cout<<endl<<"greater: "; 22 for(int i = 1; i <= n; i++) { 23 cout<<q2.top()<<' '; 24 q2.pop(); 25 } 26 cout<<endl<<"wu: "; 27 for(int i = 1; i <= n; i++) { 28 cout<<q3.top()<<' '; 29 q3.pop(); 30 } 31 }

      结果:

      

    总之岁月漫长,然而值得期待。
  • 相关阅读:
    文件的上传下载
    HttpServletResponse
    HttpServletRequest
    web工程中URL地址的推荐写法
    servlet二
    Servlet
    HTTP-崔希凡笔记
    HTTP协议-引自孤傲苍狼博客
    浏览器与服务器交互的过程
    Tomcat 配置
  • 原文地址:https://www.cnblogs.com/Hwjia/p/9614805.html
Copyright © 2011-2022 走看看