Advertisement
jtentor

DemoQueue1 - Program.cs

May 18th, 2020
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DemoQueue1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Demo Queue - versión genérica");
  14.             Queue<int> queue1 = new Queue<int>();
  15.             Queue<char> queue2 = new Queue<char>();
  16.  
  17.             Random random = new Random();
  18.  
  19.             int number;
  20.             char character;
  21.             Console.WriteLine("Enqueuing...");
  22.             for (int c = 0; c < 10; ++c)
  23.             {
  24.                 queue1.Enqueue(number = random.Next(-5000, 5001));
  25.                 queue2.Enqueue(character = (char)random.Next(65, 90));
  26.                 Console.Write("{0} {1} ", number, character);
  27.             }
  28.             Console.WriteLine();
  29.  
  30.             Console.WriteLine("Dequeuing...");
  31.             while (queue1.Count > 0)
  32.             {
  33.                 Console.Write("{0} {1} ", queue1.Dequeue(), queue2.Dequeue());
  34.             }
  35.             Console.WriteLine();
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement