Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.IO;
- namespace DICT_LMBD_And_LINQ
- {
- class Program
- {
- public static void Main()
- {
- var gradesBy = new Dictionary<string, List<double>>();
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string name = Console.ReadLine();
- double grade = double.Parse(Console.ReadLine());
- if (gradesBy.ContainsKey(name) == false)
- {
- gradesBy.Add(name, new List<double>());
- }
- gradesBy[name].Add(grade);
- }
- var sorted = gradesBy.Where(g => g.Value.Average() >= 4.50).OrderByDescending(g => g.Value.Average()).ToDictionary(x => x.Key, x => x.Value);
- foreach (var person in sorted)
- {
- Console.WriteLine("{0} -> {1:f2}", person.Key, person.Value.Average());
- }
- }
- }
- } // .
Advertisement
Add Comment
Please, Sign In to add comment