Advertisement
coregame

C++ Lab13 Deque Stack Queue

Apr 26th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <deque>
  3. #include <stack>
  4. #include <queue>
  5. #include <functional>
  6. using namespace std;
  7.  
  8. int main() {
  9.     deque<int> intDeque;
  10.     intDeque.push_back(3); intDeque.push_back(1); intDeque.push_back(2);
  11.     intDeque.push_front(4); intDeque.push_front(6); intDeque.push_front(5);
  12.     cout << "Deque: " << endl;
  13.     for (int i = 0; i < intDeque.size(); ++i) {
  14.         cout << intDeque[i] << " ";
  15.     }
  16.     cout << endl << endl;
  17.  
  18.     stack<int> intStack;
  19.     intStack.push(3); intStack.push(1); intStack.push(2);
  20.     intStack.push(4); intStack.push(6); intStack.push(5);
  21.     cout << "Stack: " << endl;
  22.     while (!intStack.empty()) {
  23.         cout << intStack.top() << " ";
  24.         intStack.pop();
  25.     }
  26.     cout << endl << endl;
  27.  
  28.     queue<int> intQueue;
  29.     intQueue.push(3); intQueue.push(1); intQueue.push(2);
  30.     intQueue.push(4); intQueue.push(6); intQueue.push(5);
  31.     cout << "Queue: " << endl;
  32.     while (!intQueue.empty()) {
  33.         cout << intQueue.front() << " ";
  34.         intQueue.pop();
  35.     }
  36.     cout << endl << endl;
  37.  
  38.     priority_queue<int> intPriorQueue;
  39.     intPriorQueue.push(3); intPriorQueue.push(1); intPriorQueue.push(2);
  40.     intPriorQueue.push(4); intPriorQueue.push(6); intPriorQueue.push(5);
  41.     cout << "Priority Queue: " << endl;
  42.     while (!intPriorQueue.empty()) {
  43.         cout << intPriorQueue.top() << " ";
  44.         intPriorQueue.pop();
  45.     }
  46.     cout << endl << endl;
  47.  
  48.     priority_queue<int, vector<int>, greater<int>> intPriorQueue2;
  49.     intPriorQueue2.push(3); intPriorQueue2.push(1); intPriorQueue2.push(2);
  50.     intPriorQueue2.push(4); intPriorQueue2.push(6); intPriorQueue2.push(5);
  51.     cout << "Another Priority Queue: " << endl;
  52.     while (!intPriorQueue2.empty()) {
  53.         cout << intPriorQueue2.top() << " ";
  54.         intPriorQueue2.pop();
  55.     }
  56.     cout << endl << endl;
  57.  
  58.     system("pause");
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement