输入班级人数,根据人数,挨个输入成绩,求平均分,求最高分最低分
Console.Write("请输入班级人数:"); int n = int.Parse(Console.ReadLine()); double [] fenshu=new double[n]; double sum = 0; for (int i = 0; i < n;i++ ) { Console.Write("请输入第"+(i+1)+"个分数:"); fenshu[i]=double.Parse(Console.ReadLine()); sum+=fenshu[i]; } for (int i = 0; i < n; i++) { for (int j = i; j < n - 1; j++) { if (fenshu[i] < fenshu[j + 1]) { double zhong = fenshu[i]; fenshu[i] = fenshu[j + 1]; fenshu[j + 1] = zhong; } } } Console.WriteLine("全班最高分是:"+fenshu[0]+"分"); Console.WriteLine("全班最低分是:"+fenshu[n - 1]+"分"); Console.WriteLine("班级平均分是:"+(sum/n)+"分"); Console.ReadLine();