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