static void Main() { int numberOfStudents = int.Parse(Console.ReadLine()); List <Student> students = new List <Student>(); for (int i = 0; i < numberOfStudents; i++) { string[] studentInfo = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string name = studentInfo[0]; List <double> studentGrades = new List <double>(); for (int j = 1; j < studentInfo.Length; j++) { studentGrades.Add(double.Parse(studentInfo[j])); } Student student = new Student(); student.Name = name; student.Grades = studentGrades; students.Add(student); } foreach (Student student in students.Where(s => s.AverageGrade() >= 5.00).OrderBy(s => s.Name).ThenByDescending(s => s.AverageGrade())) { Console.WriteLine("{0} -> {1:F2}", student.Name, student.AverageGrade()); } }
static void Main(string[] args) { Student student = new Student(); List <KeyValuePair <string, double> > results = new List <KeyValuePair <string, double> >(); int loops = int.Parse(Console.ReadLine()); for (int i = 0; i < loops; i++) { var input = Console.ReadLine().Split().ToList(); student.Name = input[0]; var skipper = input.Skip(1).ToList(); student.Grades = new List <double>(); for (int j = 0; j < skipper.Count; j++) { student.Grades.Add(double.Parse(skipper[j])); } results.Add(new KeyValuePair <string, double>(student.Name, student.AverageGrade())); } foreach (var stud in results.OrderBy(x => x.Key).ThenByDescending(x => x.Value).Where(x => x.Value >= 5.00)) { Console.WriteLine($"{stud.Key} -> {stud.Value:F2}"); } }