Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

front priority queue cpp

// CPP Program to demonstrate Priority Queue
#include <iostream>
#include <queue>
using namespace std;
 
void showpq(priority_queue<int> gq)
{
    priority_queue<int> g = gq;
    while (!g.empty()) {
        cout << '	' << g.top();
        g.pop();
    }
    cout << '
';
}
 
// Driver Code
int main()
{
    priority_queue<int> gquiz;
    gquiz.push(10);
    gquiz.push(30);
    gquiz.push(20);
    gquiz.push(5);
    gquiz.push(1);
 
    cout << "The priority queue gquiz is : ";
    showpq(gquiz);
 
    cout << "
gquiz.size() : " << gquiz.size();
    cout << "
gquiz.top() : " << gquiz.top();
 
    cout << "
gquiz.pop() : ";
    gquiz.pop();
    showpq(gquiz);
 
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #front #priority #queue #cpp
ADD COMMENT
Topic
Name
5+1 =