using System;
using System.Collections.Generic;
using System.Text;
namespace Student
{
class Program
{
static void Main(string[] args)
{
Student[] ss = new Student[5];//这是一个学生类
for (int i = 0; i < ss.Length; i++)
{
Console.Write("请输入学号:");
ss[i]. num = Convert.ToString(Console.ReadLine());
Console.Write("请输入姓名:");
ss[i]. name = Convert.ToString(Console.ReadLine());
Console.Write("请输入数学:");
ss[i]. math = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入英语:");
ss[i]. english = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入语文:");
ss[i].chinese = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < 4; i++)
{
for (int j = i+1; j < 5; j++)
{
Student temp;
if (ss[i].Average() > ss[j].Average())
{
temp = ss[i];
ss[i] = ss[j];
ss[j] = temp;
}
}
}
for (int i = 0; i < 5; i++)
{
Console.Write("学生的编号:{0}\n学生的姓名:{1}\n数学成绩:{2}\n英语成绩:{3}\n语文成绩:{4}\n平均分:{5}",
ss[i].Num, ss[i].Name, ss[i].Math, ss[i].English, ss[i].Chinese, ss[i].Average());
}
}
}
}
老提示我未将对象引用到实例是怎么回事? |