petyaminkova91

Untitled

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