Максимален минимален

mail@pastecode.io avatar
unknown
plain_text
2 years ago
994 B
1
Indexable
Never
internal class Program
    {
        static void Main(string[] args)
        {
            int[] arrNum = new int[10];
            int max = int.MinValue;
            int maximumPosition = -1;
            int min = int.MaxValue;
            int minimumPosition = -1;
 
            for (int i = 0; i < arrNum.Length; i++)
            {
                arrNum[i] = int.Parse(Console.ReadLine());
            }
 
            for (int i = 0; i < arrNum.Length; i++)
            {
                if (arrNum[i] > max)
                {
                    max = arrNum[i];
                    maximumPosition = i;
                }
 
                if (arrNum[i] < min)
                {
                    min = arrNum[i];
                    minimumPosition = i;
                }
            }
            Console.WriteLine($"MAX: {max}; Position: {maximumPosition}");
            Console.WriteLine($"MIN: {min}; Position: {minimumPosition}");
        }
    }
}