class Program
{
static void Main(string[] args)
{
int[] array = {1,3,5,2,4,6,7,9,0,8};
int max= GetMax(array);
Console.WriteLine("数组中最大的值是{0}",max);
Console.ReadKey();
}
/// <summary>
/// 数组中最大的值
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
private static int GetMax(int[] array)
{
int max = 0;
for (int i = 0; i <array.Length; i++)
{
max = max > array[i] ? max : array[i];
}
return max;
}
}
class Program
{
static void Main(string[] args)
{
int[] array = {1,3,5,2,4,6,7,9,0,8};
int max= GetMax(array);
Console.WriteLine("数组中最大的值是{0}",max);
Console.ReadKey();
}
/// <summary>
/// 数组中最大的值
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
private static int GetMax(int[] array)
{
int max = 0;
for (int i = 0; i <array.Length; i++)
{
max = max > array[i] ? max : array[i];
}
return max;
}
}