namespace _2023._06._06
{
    class Program
    {
        static void kivalogatas()
        {
            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++;
                }
            }
            System.Console.WriteLine("Eredeti:");
            for(int i = 0; i < n; i++)
            {
                System.Console.WriteLine(a[i]);
            }
            System.Console.WriteLine();
            System.Console.WriteLine("Kiválogatott:");
            for(int i = 0; i < j; i++)
            {
                System.Console.WriteLine(b[i]);
            }
            System.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 lineartomb()
        {
            var tomb = new int[] {9, 6, 0, 0, 1, 2, 2, 2, 3, 1, 5, 4, 8, 2, 8, 6};
            int poz = LinearisKereses(tomb, 8);
            System.Console.WriteLine($"A nyolcas indexe: {poz}");
        }

        static void lineartomb2()
        {
            int[] T = {101, 7, 8, 11, 255, 321};
            int n = T.Length;
            int ker = 101;
            int i = 0;
            while(i < n && T[i] != ker)
            {
                i++;
            }
            if (i < n)
            {
                System.Console.WriteLine($"Indexe: {i}");
            }
            else
            {
                System.Console.WriteLine("Nincs benne!");
            }
            string tomb = string.Join(", ", T);
            System.Console.Write(tomb);
        }
        static void Main(string[] args)
        {
            lineartomb2();
        }
    }
}