using System;
using System.Windows.Forms;

namespace _7_18
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static void MaxAndMin(int[] a)
        {
            int max = a[0];
            int min = a[0];
            int maxLoc = 0;
            int minLoc = 0;
            int n = a.Length;

            for (int i = 0; i <= n - 1; i++)
            {
                if (max < a[i])
                {
                    max = a[i];
                    maxLoc = i;
                }

                if (min > a[i])
                {
                    min = a[i];
                    minLoc = i;
                }
            }

            MessageBox.Show("Max is: " + "a[" + maxLoc + "]" + "=" + max);

            MessageBox.Show("Min is: " + "a[" + minLoc + "]" + "=" + min);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int[] a = { 10, 20, 13, 14, 15, 10, 12, 13, 10, 16 };
            MaxAndMin(a);
        }
    }
}