Advertisement
YavorGrancharov

Search_for_a_Number

Oct 13th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Search_for_a_Number
  6. {
  7.     public static void Main()
  8.     {
  9.         List<int> list = Console.ReadLine()
  10.         .Split().Select(int.Parse).ToList();
  11.        
  12.         int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  13.        
  14.         int take = input[0];
  15.         int delete = input[1];
  16.         int present = input[2];
  17.        
  18.         List<int> newList = list.Take(take).ToList();
  19.         newList.RemoveRange(0,delete);
  20.  
  21.         if(newList.Exists(x => x == present))
  22.         {
  23.             Console.WriteLine("YES!");
  24.         }
  25.         else
  26.         {
  27.             Console.WriteLine("NO!");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement