weixin_44201914 2018-12-21 11:21 采纳率: 0%
浏览 852

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

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条回答 默认 最新

  • 规陌 2018-12-21 03:43
    关注

    最大值和最小值可以运用比较的方法啊,得出最大值最小值下标就出来了,平均分直接算

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog