Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Numerics;
- using System.Runtime.CompilerServices;
- namespace ConsoleApp9
- {
- class Program
- {
- static void Main(string[] args)
- {
- var input = int.Parse(Console.ReadLine());
- var dict = new Dictionary<string,List<double>>();
- for (int i = 0; i < input; i++)
- {
- string[] command = Console.ReadLine().Split(" ",StringSplitOptions.RemoveEmptyEntries).ToArray();
- string name = command[0];
- double grade = double.Parse(command[1]);
- if (!dict.ContainsKey(name))
- {
- dict.Add(name,new List<double>());
- }
- dict[name].Add(grade);
- }
- foreach (var grades in dict)
- {
- Console.Write($"{grades.Key} -> ");
- foreach (var number in grades.Value)
- {
- Console.Write($"{number:F2} ");
- }
- Console.Write($"(avg: {grades.Value.Average():F2})");
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement