Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Ejercicio3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Queue<int> queue1 = new Queue<int>();
- Queue<char> queue2 = new Queue<char>();
- Random random = new Random();
- Console.WriteLine("Cantidad de Elementos en la primer cola: ");
- int l1 = Convert.ToInt16(Console.ReadLine());
- for (int c = 0; c < l1; c++)
- {
- queue1.Enqueue(random.Next(0, 9));
- }
- Console.WriteLine("Cantidad de Elementos en la segunda cola: ");
- int l2 = Convert.ToInt16(Console.ReadLine());
- for (int c = 0; c < l2; c++)
- {
- queue2.Enqueue((char)random.Next(65, 90));
- }
- Console.WriteLine("QUEUE 1");
- foreach (int value in queue1)
- {
- Console.WriteLine("|_{0}_|",value);
- }
- Console.WriteLine("QUEUE 2");
- foreach (char value in queue2)
- {
- Console.WriteLine("|_{0}_|", value);
- }
- Console.WriteLine("Union entre colas -> [PressEnter]");
- Console.ReadKey();
- Console.Clear();
- UnionColas(queue1, queue2);
- Console.ReadKey();
- }
- public static void UnionColas(Queue<int> q1, Queue<char> q2)
- {
- Queue<object> Resultado = new Queue<object>();
- foreach (int value in q1)
- {
- Resultado.Enqueue(value);
- }
- foreach (char value in q2)
- {
- Resultado.Enqueue(value);
- }
- Console.WriteLine("UNION");
- foreach (object value in Resultado)
- {
- Console.WriteLine("|_{0}_|",value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement