Advertisement
jtentor

DemoQueue1 - DemoQueue1.cpp

May 17th, 2020
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. //
  2. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  3. //
  4.  
  5. #include <iostream>
  6. #include "queue.h"
  7. #include <stdlib.h>
  8. #include <time.h>
  9.  
  10. int main() {
  11.     std::cout << "Demo Queue - versión genérica" << std::endl;
  12.     queue<int> queue1 = queue<int>();
  13.     queue<char> queue2 = queue<char>();
  14.  
  15.     std::srand((unsigned int)time(NULL));
  16.  
  17.     int number;
  18.     char character;
  19.     std::cout << "Enqueuing..." << std::endl;
  20.     for (int c = 0; c < 10; ++c) {
  21.         queue1.push(number = std::rand() % 10000 - 5000);
  22.         queue2.push(character = std::rand() % 25 + 65);
  23.         std::cout << number << " " << character << " ";
  24.     }
  25.     std::cout << std::endl;
  26.  
  27.     std::cout << "Dequeuing..." << std::endl;
  28.     while (queue1.size() > 0) {
  29.         std::cout << queue1.front() << " " << queue2.front() << " ";
  30.         queue1.pop();
  31.         queue2.pop();
  32.     }
  33.     std::cout << std::endl;
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement