193030

Queue

Apr 15th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3.  
  4. using namespace std;
  5. void showQ(queue <int> inputQ)
  6. {
  7.     queue <int> tempQ = inputQ;
  8.  
  9.     while(!tempQ.empty())
  10.     {
  11.         cout << tempQ.front() << " ";
  12.         tempQ.pop();
  13.     }
  14. }
  15.  
  16. int main()
  17. {
  18.     queue <int> myQueue;
  19.  
  20.     myQueue.push(10);
  21.     myQueue.push(20);
  22.     myQueue.push(30);
  23.     showQ(myQueue); // Shows the queue
  24.     cout << endl << "The size of the queue is : " << myQueue.size() << endl;
  25.     cout << "myQueue.front() is: " << myQueue.front() << endl;
  26.     cout << "myQueue.back() is: " << myQueue.back() << endl;
  27.  
  28. }
Add Comment
Please, Sign In to add comment