Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp4
- {
- class Program
- {
- class Student
- {
- public string Name { get; set; }
- public List<double> grades { get; set; }
- public double averageGrade { get; set; }
- }
- static void Main(string[] args)
- {
- var count = int.Parse(Console.ReadLine());
- var excellentStudents = new List<Student>();
- for (int i = 0; i < count; i++)
- {
- string[] input = Console.ReadLine().Split().ToArray();
- Student std = new Student();
- std.Name = input[0];
- for (int j = 1; j < input.Length; j++)
- {
- std.grades.Add(Convert.ToDouble(input[j]));
- }
- std.averageGrade = std.grades.Average();
- if (std.averageGrade >= 5.00)
- {
- excellentStudents.Add(std);
- }
- }
- excellentStudents = excellentStudents.OrderBy(x => x.Name).ThenByDescending(x => x.averageGrade).ToList();
- foreach(Student ex in excellentStudents)
- {
- Console.WriteLine($"{ex.Name} -> {ex.averageGrade}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement