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