Advertisement
jtentor

DemoQueue4 - DemoQueue4.cpp

May 17th, 2020
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. //
  2. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  3. //
  4.  
  5. #include <iostream>
  6. #include "specialqueue.h"
  7. #include <stdlib.h>
  8. #include <time.h>
  9.  
  10. int main() {
  11.     std::cout << "Demo Queue - versión librería estándar - Caso Ejemplo b)" << std::endl;
  12.  
  13.     specialqueue<int> queue1 = specialqueue<int>();
  14.  
  15.     std::srand((unsigned int)time(NULL));
  16.  
  17.     int number;
  18.     std::cout << "Enqueuing..." << std::endl;
  19.     for (int c =0 ; c < 10; ++c) {
  20.         queue1.push(number = std::rand() % 10);
  21.         std::cout << number << " ";
  22.     }
  23.     std::cout << std::endl;
  24.  
  25.     std::cout << "Joining with same queue..." << std::endl;
  26.     specialqueue<int> queue2 = queue1.join(queue1);
  27.  
  28.     std::cout << "Dequeuing..." << std::endl;
  29.     while (queue1.size() > 0) {
  30.         std::cout << queue1.front() << " ";
  31.         queue1.pop();
  32.     }
  33.     std::cout << std::endl;
  34.  
  35.     std::cout << "Dequeuing joined queue..." << std::endl;
  36.     while (queue2.size() > 0) {
  37.         std::cout << queue2.front() << " ";
  38.         queue2.pop();
  39.     }
  40.     std::cout << std::endl;
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement