namespace 集合习题练一练
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入你们班的人数:");
int n = Convert.ToInt32(Console.ReadLine());
ArrayList al = new ArrayList();
for (int i = 0; i < n; i++)
{
Console.WriteLine("第"+(i+1)+"个同学的成绩为:");
al.Add(Convert.ToInt32(Console.ReadLine()));
}
for (int i = 0; i < al.Count; i++)
{
Console.WriteLine("同学们的成绩依次为"+al[i]+"分");
}
double sum = 0;
for (int i = 0; i < n; i++)
{
sum = sum + Convert.ToInt32(al[i]);
}
Console.WriteLine("总分为"+sum+"分");
al.Sort();
for (int i = 0; i < al.Count; i++)
{
Console.WriteLine("同学们的成绩按照一定顺序排列为" + al[i] + "分");
}
double ave = 0;
ave = (sum - Convert.ToInt32(al[0]) - Convert.ToInt32(al[4])) / (al.Count-2);
Console.WriteLine("你们班的平均分为"+ave+"分");
Console.ReadLine();
}
}
}
原文:http://www.cnblogs.com/lk-kk/p/4404105.html