public static void Swap(ref Entrant a, ref Entrant b) { Entrant temp = a; a = b; b = temp; }
static Entrant[] ReadEntrantsArray() { Entrant[] ents = new Entrant[n]; for (int i = 0; i < n; i++) { Console.WriteLine("Name: "); ents[i].Name = Console.ReadLine(); Console.WriteLine("Id: "); ents[i].IdNum = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Course points: "); ents[i].CoursePoints = Convert.ToSingle(Console.ReadLine()); Console.WriteLine("Average points: "); ents[i].AvgPoints = Convert.ToSingle(Console.ReadLine()); ZNO[] znoArr = new ZNO[3]; for (int j = 0; j < 3; j++) { Console.WriteLine($"ZNO subject {j + 1}: "); znoArr[j].Subject = Console.ReadLine(); Console.WriteLine($"ZNO point {j + 1}: "); znoArr[j].Points = Convert.ToInt32(Console.ReadLine()); } ents[i].ZNOResults = znoArr; Console.WriteLine(""); } return(ents); }
public static void SortEntrantsByName(ref Entrant[] ents) { for (int i = 0; i < ents.Length; i++) { for (int j = 0; j < ents.Length - 1; j++) { if (NeedToReOrder(ents[j].Name, ents[j + 1].Name)) { Entrant temp = ents[j]; ents[j] = ents[j + 1]; ents[j + 1] = temp; } } } }
public static void PrintEntrant(Entrant entrant) { Console.WriteLine("Name: "); Console.WriteLine(entrant.Name); Console.WriteLine("Id: "); Console.WriteLine(entrant.IdNum); Console.WriteLine("Course points: "); Console.WriteLine(entrant.CoursePoints); Console.WriteLine("Average points: "); Console.WriteLine(entrant.AvgPoints); for (int i = 0; i < 3; i++) { Console.WriteLine($"ZNO point {i + 1}: "); Console.WriteLine(entrant.ZNOResults[i].Points); } }
public static void GetEntrantsInfo(Entrant[] ents, out Entrant min, out Entrant max) { Entrant mn = ents[0], mx = ents[0]; for (int i = 1; i < ents.Length; i++) { if (ents[i].GetCompMark() < mn.GetCompMark()) { mn = ents[i]; } if (ents[i].GetCompMark() > mx.GetCompMark()) { mx = ents[i]; } } min = mn; max = mx; }