Advertisement
KKK99

07.StudetsAcademy

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