Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Task1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int N = int.Parse(Console.ReadLine());
- Dictionary<string, List<double>> grades = new Dictionary<string, List<double>>();
- for (int i = 0; i < N; i++)
- {
- string[] input = Console.ReadLine().Split(' ');
- string name = input[0];
- double grade = double.Parse(input[1]);
- if (!grades.ContainsKey(name))
- {
- grades[name] = new List<double>();
- }
- grades[name].Add(grade);
- }
- foreach (KeyValuePair<string, List<double>> item in grades)
- {
- string name = item.Key;
- List<double> studentsGrades = item.Value;
- double average = studentsGrades.Average();
- Console.Write($"{name} -> ");
- foreach (var value in studentsGrades)
- {
- Console.Write($"{value:f2} ");
- }
- Console.WriteLine($"(avg: {average:f2})");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement