namespace projGetMaxScore
{
class Program
{
static void Main(string[] args)
{
Class[] c1 = new Class[] { new Class("吴松",89),new Class("钱东宁",90),new Class("伏晨",98),new Class("陈陆",56)
,new Class("周蕊",60),new Class("林日鹏",91),new Class("何昆",93),new Class("关欣",85)};
int maxGrade = 0;
string maxName = null;
for (int i = 0; i < c1.Length; i++)
{
if (maxGrade < c1[i]._grade)
{
maxGrade = c1[i]._grade;
maxName = c1[i]._name;
}
}
Console.WriteLine("分数最高的是"+maxName+",分数是"+maxGrade);
}
}
class Class
{
public string _name;
public int _grade;
public Class(string name, int grade)
{
_name = name;
_grade = grade;
}
}
}
}
}
我之前没看提示要用两个数组,就根据习惯这样写的,但是过不了...
你的那个逗号换成中文符号再试试