using System;
using System.Collections.Generic;
using System.Text;
namespace 一维数组求最大值最小值
{
class Program
{
static void Main(string[] args)
{
int[] quene = new int[10] {89,78,65,52,90,92,73,85,91,95 };
int max, min;
max = min = quene[0];
for (int i = 0; i < quene.Length; i++)
{
if (quene[i] > max)
max = quene[i];
if (quene[i] < min)
min =quene [i ];
}
Console.WriteLine("最大值为:{0},最小值为{1}",max ,min );
}
}
}
为什么这样可以求出最小值,比quene[0]大或小的数不是有那么多个么?为什么会选择最大或者最小的呢?是什么原理?