weixin_44201914
weixin_44201914
2018-12-21 11:21

用面向对象的思想来求解10个学生成绩中的最大值、最小值、及他们所对应的下标,求出平均分

  • c语言

using System;
using System.Collections.ObjectModel;
using System.Linq;

namespace TextTest
{
public class Students:Collection此处的collection总是显示缺少类型,请问缺少的是什么类型

{
public double AverageScore()
{
return Items.Average(s=>s.Score);
}
public int MaxScore()
{
return Items.Max(s=>s.Score);
}
public Student MaxScoreStudent()
{
int maxScore=MaxScore();
return Items.First(s=>s.Score==maxScore);
}
public int MaxScoreStudentId()
{
return Items.IndexOf(MaxScoreStudent());
}
public int MinScore()
{
return Items.Min(s=>s.Score);
}
public Student MinScoreStudent()
{
int minScore=MinScore();
return Items.First(s=>s.Score==minScore);
}

public int MinScoreStudentId()
{
int minScore=MinScore();
return Items.IndexOf(MinScoreStudent());
}
}
public class Student
{
private string _Id;

public string Id
{
get {return _Id;}
set {_Id=value;}
}
private int _Score;

public int Score
{
get{return _Score;}
set{_Score =value;}
}
}
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答