Console.WriteLine("请输入班级的人数:");
int num = int.Parse(Console.ReadLine());
Student[] s = new Student[num];
for (int i = 0; i < s.Length; i++)
{
s[i] = new Student();
Console.WriteLine("请输入学生{0}的姓名:", i + 1);
s[i].name = Console.ReadLine();
Console.WriteLine("请输入学生{0}的年龄:", s[i].name);
s[i].age = int.Parse(Console.ReadLine());
}
Console.WriteLine("该班级有以下学生:");
String a;
for (int i = 0; i < s.Length - 1;i++ )
{
for (int j = 0; j < s.Length - i - 1;j++ )
{
if(s[j].name.CompareTo(s[j+1].name )<0)
{
a = s[j];
s[j]=s[j+1];
s[j + 1] = a;
}
}
}
Console.ReadLine();