Advertisement
Guest User

Softuni, Lists Excercises, 3.Search For A Number

a guest
Oct 10th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 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 _3.SearchForANumber
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.             var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  15.             List<int> listOperations = new List<int>();
  16.             bool isTrue = false;
  17.             for (int i = 0; i < array[0]; i++)
  18.             {
  19.                 listOperations.Add(numbers[i]);
  20.             }
  21.             for (int i = 0; i < array[1]; i++)
  22.             {
  23.                 listOperations.RemoveAt(i);
  24.             }
  25.             for (int i = 0; i < listOperations.Count; i++)
  26.             {
  27.                 if (listOperations[i] == array[2])
  28.                 {
  29.                     isTrue = true;
  30.                 }
  31.             }
  32.             if (isTrue == true)
  33.             {
  34.                 Console.WriteLine("YES!");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine("NO!");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement