public static void GetAllMarksOfStudent WithChanges string lastName st

 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
48
49
public static void GetAllMarksOfStudentWithChanges (string lastName, string firstName, string secondName)
{
LinkedList<int> studentIDs = new LinkedList<int> (
(from student in studentsList
where (student.LastName == lastName) && (student.FirstName == firstName) && (student.SecondName == secondName)
select student.ID).ToList()
);
int currentStudentID = studentIDs.First.Value;
int currentID;
int i;
// Двигаемся от текущей позиции влево
currentID = currentStudentID;
i = changesList.FindIndex ( change => change.NewID == currentID );
if (i != -1) {
for (; i >= 0; i--) {
if (changesList [i].NewID == currentID) {
currentID = changesList [i].OldID;
studentIDs.AddFirst (currentID);
}
}
}
// Двигаемся от текущей позиции вправо
currentID = currentStudentID;
i = changesList.FindIndex( change => change.OldID == currentID );
if (i != -1) {
for (; i < changesList.Count; i++) {
if (changesList [i].OldID == currentID) {
currentID = changesList [i].NewID;
studentIDs.AddLast (currentID);
}
}
}
var marks =
from mark in marksList
join student in studentIDs
on mark.StudentID equals student
orderby mark.SessionNumber ascending,
mark.Subject ascending,
mark.Status ascending
select mark;
foreach (var session in sessions) {
// выводишь оценку
Console.WriteLine ();
}
}