求平均数,排列顺序为降序
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { ArrayList al = new ArrayList(); Console.WriteLine("请输入人数"); int n =int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { Console.Write("请输入第"+(i+1)+"个学生的分数:"); al.Add(int.Parse(Console.ReadLine())); } double he = 0; for(int b =0;b<n;b++) { he = he + double.Parse(al[b].ToString()); } double pj = he / n; Console.WriteLine("平均分为"+pj); al.Sort(); al.Reverse(); for (int d = 0; d < n; d++) { Console.WriteLine(al[d]); } Console.ReadLine(); } } }