using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Feladat1() { int[] a = { 9, 7, 3, 5, 4, 2, 6 }; int n = a.Length; int[] b = new int[n]; int j = 0; for (int i = 0; i < n; ++i) if (a[i] < 5) { b[j] = a[i]; ++j; } Console.WriteLine("Eredeti: "); for (int i = 0; i < n; ++i) Console.WriteLine($"{a[i]} "); Console.WriteLine(""); Console.WriteLine("Kivlogatott: "); for (int i = 0; i < j; ++i) Console.WriteLine($"{b[i]} "); Console.WriteLine(""); } public static int Lineariskereses(int[] tomb, int elem) { int index = -1; for (int i = 0; i < tomb.Length; ++i) { if (tomb[i] == elem) { index = i; break; } } return index; } static void Feladat2() { int[] a = { 9, 7, 3, 5, 4, 2, 6 }; int elem = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Lineariskereses(a,elem)); } static void Main(string[] args) { Feladat2(); Console.ReadKey(); } } }