Console.WriteLine("请输入学生人数:"); int n=int.Parse(Console.ReadLine()); ArrayList arr= new ArrayList(); for (int i = 0; i <n; i++) { Console.WriteLine("输入的第{0}个人的成绩是:",i+1); arr.Add(int.Parse(Console.ReadLine())); } foreach(int a in arr) { Console.Write(a+" "); } Console.WriteLine(); double sum = 0; int max = 0; for (int j = 0; j < n; j++) { if (int.Parse(arr[j].ToString()) > max)//int.parse只能将字符串类型转换为int类型. { max=int.Parse(arr[j].ToString()); } sum += double.Parse(arr[j].ToString());//arr[j]输出默认为object 类型.... } double avg=sum/n; Console.WriteLine("最高分为"+max); Console.WriteLine("平均分为"+avg); Console.ReadLine();