TonyTroev

Look For A Number In A List

Feb 1st, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _47_LookingForANumber
  8. {
  9.     class LookingForANumber
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> numbers = Console.ReadLine()
  14.                 .Split(' ')
  15.                 .Select(int.Parse)
  16.                 .ToList();
  17.             List<int> condition = Console.ReadLine()
  18.                 .Split(' ')
  19.                 .Select(int.Parse)
  20.                 .ToList();
  21.  
  22.             numbers = numbers.Take(condition[0]).ToList();
  23.             numbers.RemoveRange(0, condition[1]);
  24.             Console.WriteLine((numbers.Contains(condition[2])) ? "YES!" : "NO!");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment