Advertisement
jtentor

DemoQueue2 - DemoQueue2.cpp

May 17th, 2020
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. //
  2. // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
  3. //
  4.  
  5. #include <iostream>
  6. #include <queue>
  7. #include <stdlib.h>
  8. #include <time.h>
  9.  
  10. int main() {
  11.     std::cout << "Demo Queue - versión librería estándar" << std::endl;
  12.     std::queue<int> queue1 = std::queue<int>();
  13.     std::queue<char> queue2 = std::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