Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace tp3e8
- {
- public class Program
- {
- public static void Main()
- {
- int l, c, j;
- Queue<int> cola1 = new Queue<int>();
- Queue<int> cola2 = new Queue<int>();
- Console.WriteLine("Ingrese el tamaño que tendran las colas");
- c = Int32.Parse(Console.ReadLine());
- Console.WriteLine("Ingrese los valores para la 1° Cola");
- for (j = 0; j < c; j++)
- {
- l = Int32.Parse(Console.ReadLine());
- cola1.Enqueue(l);
- }
- Console.WriteLine("Ingrese los valores para la 2° Cola");
- for (j = 0; j < c; j++)
- {
- l = Int32.Parse(Console.ReadLine());
- cola2.Enqueue(l);
- }
- c = CompararColas(cola1, cola2);
- switch (c)
- {
- case 1:
- Console.WriteLine("La 1° Cola es MAYOR que la 2° Cola");
- break;
- case -1:
- Console.WriteLine("La 1° Cola es MENOR que la 2° Cola");
- break;
- case 0:
- Console.WriteLine("Las Colas son IGUALES");
- break;
- }
- }
- public static int CompararColas(Queue<int> cola1, Queue<int> cola2)
- {
- for (int i = 0; i < cola1.Count; i++)
- {
- if (cola1.Peek() > cola2.Peek())
- {
- return 1;
- }
- else if (cola1.Peek() < cola2.Peek())
- {
- return -1;
- }
- cola1.Dequeue();
- cola2.Dequeue();
- }
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement