static void Main(string[] args)
{
int[] nums= { 1, 2, 3 };
int sum, max, mix;
sum = compute( nums, out mix, out max);
Console.WriteLine("数组里面的最大值为{0},最小值为{1},和为{2}",max,mix,sum);
Console.ReadKey();
}
static int compute( int [] i2, out int mix, out int max)
{
int sum = 0;
max = i2[0];
mix = i2[0];
for (int i = 0; i < i2.Length; i++)
{
sum += i2[i];
if (max < i2[i])
{
max = i2[i];
}
if (mix > i2[i])
{
mix = i2[i];
}
}
} |