1 Star 0 Fork 0

小胡不糊涂/windows

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
windows程序设计作业2 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
using System;
public class Student : IComparable
{
public double mygrade;
public string mysubject, myID;
public Student() { }
public Student(double grade, string subject, string id)
{
mygrade = grade;
mysubject = subject;
myID = id;
}
int IComparable.CompareTo(Object obj)
{
if (obj is Student)
{
Student s = (Student)obj;
if (this.mygrade > s.mygrade) { return 1; }
else if (this.mygrade < s.mygrade) { return -1; }
else { return 0; }
}
throw new ArgumentException("object is not a Student");
}
}
internal class Program
{
private static void Main(string[] args)
{
Student[] students = new Student[5];
students[0] = new Student(50.0, "windows程序设计", "001");
students[1] = new Student(90.0, "windows程序设计", "002");
students[2] = new Student(100.0, "windows程序设计", "003");
students[3] = new Student(70.0, "windows程序设计", "004");
students[4] = new Student(80.0, "windows程序设计", "005");
Array.Sort(students);
foreach (Student student in students)
{
Console.WriteLine(student.mygrade + " " + student.mysubject + " " + student.myID);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/Hututu0921/windows.git
git@gitee.com:Hututu0921/windows.git
Hututu0921
windows
windows
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385