Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class StudentsAcademy
- {
- static void Main(string[] args)
- {
- Dictionary<string, double[]> inputDict = new Dictionary<string, double[]>();
- int num = int.Parse(Console.ReadLine());
- int count;
- for (int i = 0; i < num; i++)
- {
- string input = Console.ReadLine();
- double grade = double.Parse(Console.ReadLine());
- if (!inputDict.ContainsKey(input))
- {
- count = 1;
- inputDict.Add(input, new double[2] {grade, 1});
- }
- else
- {
- inputDict[input][1] += 1;
- inputDict[input][0] += grade;
- }
- }
- foreach (var item in inputDict)
- {
- inputDict[item.Key][0] /= inputDict[item.Key][1];
- }
- foreach (var kvp in inputDict.OrderByDescending(w => w.Value[0]))
- {
- if (kvp.Value[0] >= 4.50)
- {
- Console.WriteLine($"{kvp.Key} -> {kvp.Value[0]:f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement