Advertisement
mdamyanova

Untitled

May 25th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Exercises
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.             var stack = new Stack<int>();
  13.             int[] numbers = new int[input[0]];
  14.             numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
  15.  
  16.             foreach (var num in numbers)
  17.             {
  18.                 stack.Push(num);
  19.             }
  20.  
  21.  
  22.             for (int i = 0; i < input[1]; i++)
  23.             {
  24.                 stack.Pop();
  25.             }
  26.  
  27.             if (stack.Contains(input[2]))
  28.             {
  29.                 Console.WriteLine("true");
  30.             }
  31.             else
  32.             {
  33.              
  34.               if (stack.Count != 0)
  35.               {
  36.                   Console.WriteLine(stack.Min());
  37.               }
  38.               else
  39.               {
  40.                  Console.WriteLine(0);
  41.               }
  42.                            
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement