从一个整数数组中取出最大,最小的整数和总和
int[] a = { 12, 2, 99, 6, 1 ,0}; int Max = 0; int Min = 0; for (int i = 0; i < a.Length; i++) { if (a[i] > Max) { Max = a[i]; } if (a[i] < Max) { Min = a[i]; } } int All = Max + Min; Console.WriteLine(Max); Console.WriteLine(Min); Console.WriteLine(All);
Console.ReadKey();