Advertisement
bacco

Search for a Number

Jun 5th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace SearchforaNumber
  7. {
  8.     class MainClass
  9.     {
  10.         public static void Main(string[] args)
  11.         {
  12.             List<int> numbers = Console.ReadLine()
  13.                                        .Split(' ')
  14.                                        .Select(int.Parse)
  15.                                        .ToList();
  16.  
  17.             int[] commands = Console.ReadLine()
  18.                                     .Split(' ')
  19.                                     .Select(int.Parse)
  20.                                     .ToArray();
  21.  
  22.             if( numbers.Take(commands[0])
  23.                        .Skip(commands[1])
  24.                        .Contains(commands[2]) )
  25.             {
  26.                 Console.WriteLine("YES!");
  27.             }
  28.             else
  29.             {
  30.                 Console.WriteLine("NO!");
  31.             }
  32.         }                            
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement