Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ queue

// CPP code to illustrate Queue in
// Standard Template Library (STL)
#include <iostream>
#include <queue>
 
using namespace std;
 
// Print the queue
void showq(queue<int> gq)
{
    queue<int> g = gq;
    while (!g.empty()) {
        cout << '	' << g.front();
        g.pop();
    }
    cout << '
';
}
 
// Driver Code
int main()
{
    queue<int> gquiz;
    gquiz.push(10);
    gquiz.push(20);
    gquiz.push(30);
 
    cout << "The queue gquiz is : ";
    showq(gquiz);
 
    cout << "
gquiz.size() : " << gquiz.size();
    cout << "
gquiz.front() : " << gquiz.front();
    cout << "
gquiz.back() : " << gquiz.back();
 
    cout << "
gquiz.pop() : ";
    gquiz.pop();
    showq(gquiz);
 
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #queue
ADD COMMENT
Topic
Name
1+9 =