Rosen_Tenev

Student Academy

Mar 20th, 2019
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Student_Academy
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int num = int.Parse(Console.ReadLine());
  12. var infoStudents = new Dictionary<string, List<double>>();
  13.  
  14. for (int i = 1; i <= num; i++)
  15. {
  16. string name = Console.ReadLine();
  17. double grade = double.Parse(Console.ReadLine());
  18. if (!infoStudents.ContainsKey(name))
  19. {
  20. infoStudents.Add(name, new List<double>());
  21. infoStudents[name].Add(grade);
  22.  
  23. }
  24. else
  25. {
  26. infoStudents[name].Add(grade);
  27. }
  28. }
  29.  
  30. foreach (var kvp in infoStudents.OrderByDescending(x=>x.Key).ThenBy(x=>x.Value.Average()))
  31. {
  32.  
  33. if ((kvp.Value.Average()) >= 4.50)
  34. {
  35. Console.WriteLine($"{kvp.Key} -> {(kvp.Value.Average()):f2}");
  36. }
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment