elena1234

Search a specific element

Dec 4th, 2021 (edited)
720
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace SearchElement
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int[] numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.  
  13.             int findNumber = 5;
  14.  
  15.             int index = Array.IndexOf(numbers, findNumber);
  16.             if(index > 0)
  17.             {
  18.                 Console.WriteLine(true);
  19.                 Console.WriteLine(index);
  20.             }
  21.  
  22.         }
  23.     }
  24. }
  25.  
RAW Paste Data