Advertisement
mausha

BasicQueueOperations

May 30th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace EXER_BasicQueueOperations
  6. {
  7.     public class QueueOpers
  8.     {
  9.         public static void Main()
  10.         {
  11.             var operators = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.             var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
  13.  
  14.             var queue = new Queue<int>();
  15.             for (int i = 0; i < operators[0]; i++)
  16.             {
  17.                 queue.Enqueue(input[i]);
  18.             }
  19.  
  20.             for (int j = 0; j < operators[1]; j++)
  21.             {
  22.                 queue.Dequeue();
  23.             }
  24.  
  25.             if (queue.Contains(operators[2]))
  26.             {
  27.                 Console.WriteLine("true");
  28.             }
  29.             else if (queue.Count > 0)
  30.             {
  31.                 Console.WriteLine(queue.Min());
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine(0);
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement