-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (38 loc) · 1.21 KB
/
Copy pathProgram.cs
File metadata and controls
47 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var rankedList = new SortedSet.SortedSet<string>();
// 添加一些测试数据
rankedList.Add("A", 3);
rankedList.Add("B", 5);
rankedList.Add("C", 11);
rankedList.Add("D", 14);
rankedList.Add("E", 19);
rankedList.Add("F", 23);
rankedList.Add("G", 25);
rankedList.Add("H", 31);
rankedList.Add("I", 39);
rankedList.Add("J", 43);
rankedList.Remove("A");
rankedList.Remove("D");
rankedList.Remove("G");
rankedList.Remove("j");
rankedList.Add("A", 3);
rankedList.Add("D", 14);
rankedList.Add("G", 25);
rankedList.Add("J", 43);
// 打印结构
rankedList.PrintStructure();
Console.WriteLine();
// 测试各种功能
Console.WriteLine("=== 功能测试 ===");
// 获取排名
Console.WriteLine($"A 的排名: {rankedList.GetReverseRank("A")}");
Console.WriteLine($"A 的逆序排名: {rankedList.GetRank("A")}");
// 获取前3名
List<string> tempList = [];
rankedList.GetTopN(10, tempList);
Console.WriteLine($"前10名: {string.Join(", ", tempList)}");
// 按排名范围查询
rankedList.GetRangeByRank(2, 4, tempList);
Console.WriteLine($"GetRangeByRank: {string.Join(", ", tempList)}");
// 按分数范围查询
rankedList.GetRangeByScore(10, 20, tempList);
Console.WriteLine($"区间分数的人: {string.Join(", ", tempList)}");