zoukankan      html  css  js  c++  java
  • 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
        *********
        ********
        *******
        ******
        *****
        ****
        ***
        **
        *
    */ 
  • 相关阅读:
    .dll 无法查找或者打开PDB文件
    VC++中解决“在查找预编译头使用时跳过”的方法
    如何重置设置开发环境
    opencv与VS的配置
    supermap开发webgis的经验
    Json 与GeoJson
    地理配准
    DBMS
    C#三层构架
    重装系统简要步骤
  • 原文地址:https://www.cnblogs.com/laohaozi/p/12537808.html
Copyright © 2011-2022 走看看