static void Main(string[] args) { int[] a = { 6, 8, 9, 5, 2, 165, 58966 }; Console.WriteLine("最大值为{0}",max(a)); Console.WriteLine("最小值为{0}",min(a)); Console.ReadKey(); } public static int max(int[] wo) { int max = wo[0]; for (int i = 0; i < wo.Length; i++) { if (wo[i] > max) { max = wo[i]; } } return max; } public static int min(int[] wo) { int min =wo[0]; for (int i = 0; i < wo.Length; i++) { if (min>wo[i]) { min = wo[i]; } } return min; }