public static void Main(string[] args)
{
double[] a = { 9.8, 12, 45, 67, 23, 1.98, 2.55, 45 };
double min = 10000;
double max = 0;
for (int i = 0; i < a.Length - 1; i++) //找出数组的最大最小值
{
if (a[i] > a[i + 1])
{
min = a[i + 1];
if (a[i] > max)
{
max = a[i];
}
else
{
i++;
}
}
else
{
min = a[i];
max = a[i + 1];
}
}
Console.WriteLine((min+max)/2);
Console.ReadKey();
}