• priority_queue-all priority_que functions


    ////////////////////////////////////////
    //      2018/05/08 22:57:50
    //      priority_queue-all priority_que functions
    
    // Priority Queues are like queues,but the elements inside the data structor are 
    // order by some predicate.
    
    #include <iostream>
    #include <queue>
    #include <vector>
    #include <string>
    
    using namespace std;
    
    int main(){
        priority_queue<int, vector<int>, less<int>> ipq;
        ipq.push(100);
        ipq.push(200);
        ipq.push(300);
    
        cout << "size of priority_queue ipq  = " << ipq.size() << endl;
    
        cout << "ipq<int, vector<int>, less<int>> = ";
        while (!ipq.empty()){
            cout << ipq.top() << " ";
            ipq.pop();
        }
        cout << endl;
    
        cout << "priority_queue<string,vector<string>> spq" << endl;
    
        priority_queue<string, vector<string>> spq;
        for (int i = 1; i < 10; i++){
            spq.push(string(i,'*'));
        }
    
        while (!spq.empty()){
            cout << spq.top() << endl;
            spq.pop();
        }
        return 0;
    }
    
    
    /*
    OUTPUT:
        size of priority_queue ipq  = 3
        ipq<int, vector<int>, less<int>> = 300 200 100
        priority_queue<string,vector<string>> spq
        *********
        ********
        *******
        ******
        *****
        ****
        ***
        **
        *
    */ 
  • 相关阅读:
    Number Two
    蝴蝶结
    webug3.0靶场渗透基础Day_1
    SQL SERVER2014的安装
    SQLILABS学习笔记(一)
    关于暴力破解的一些学习笔记(pikachu)
    sql注入学习笔记
    CSRF与平行越权的区别
    任意文件下载(pikachu)
    XSS跨站脚本攻击学习笔记(pikachu)
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12537808.html
Copyright © 2020-2023  润新知