using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[] height = new double[10];
double sum=0,avger,her;
for (int i = 0; i <= 9; i++)
{
Console.Write("请输入一个数:");
height[i] = double.Parse(Console.ReadLine());
sum = sum + height[i];
}
for (int i = 9; i >= 1; i–)
{
for (int b = 0; b <= i-1; b++)
{
if (height[i] < height[b])
{
her = height[i];
height[i] = height[b];
height[b] = her;
}
}
}
avger=sum/10;
Console.WriteLine("平均值为{0}", avger);
for (int i = 0; i < height.Length; i++)
{
Console.Write("{0} ", height[i]);
}
Console.ReadKey();
}
}
}
效果图:
评论