namespace test001
{
internal class Program
{
static void Main(string[] args)
{
double[] numbers = new double[1000];
int count = 0;
Console.WriteLine("请您输入一组数字(输入-999结束运行):");
while (true)
{
double a = double.Parse(Console.ReadLine());
if (a == -999) break;
else
{
numbers[count] = a;
count++;
}
}
double max = numbers[0];
double min = numbers[0];
double sum = 0;
for (int i = 0; i < count; i++)
{
sum += numbers[i];
if (numbers[i] > max)
max = numbers[i];
if (numbers[i] < min)
{
min = numbers[i];
}
}
double average = (sum) / count;
Console.WriteLine("数组的最大值是:{0}", max);
Console.WriteLine("数组的最小值是:{0}", min);
Console.WriteLine("数组的总和是:{0}", sum);
Console.WriteLine("数组的平均值是:{0}", average);
Console.ReadKey();
}
}
}