using System; using System.Collections; using System.Collections.Generic; using System.Text; namespace ConsoleApplication40 { class Program { struct student { public string xueshengname; public int xuehao; public int fenshu; } public ArrayList paixu(ArrayList al) { for (int i = 0; i < al.Count; i++) { for (int j = i; j < al.Count - 1; j++) { if (((student)al[i]).fenshu < ((student)al[j + 1]).fenshu) { student temp = (student)al[i]; al[i] = al[j + 1]; al[j + 1] = temp; } } } return al; } static void Main(string[] args) { ArrayList al = new ArrayList(); student a = new student(); Console.WriteLine("请输入人数"); int n = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < n; i++) { Console.WriteLine("请输入第"+(i+1)+"人的姓名"); a.xueshengname = Console.ReadLine(); Console.WriteLine("请输入第" + (i + 1) + "人的学号"); a.xuehao = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("请输入第" + (i + 1) + "人的成绩"); a.fenshu = Convert.ToInt32(Console.ReadLine()); al.Add(a); } new Program().paixu(al); for (int i = 0; i < n; i++) { Console.WriteLine((((student)al[i]).xueshengname) + " " + (((student)al[i]).xuehao) + " " + (((student)al[i]).fenshu)); } Console.ReadLine(); } } }