Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _4.AverageGrades
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Program
- {
- public static void Main(string[] args)
- {
- var number = int.Parse(Console.ReadLine());
- var studentByAverageGrade = new Dictionary<string, double>();
- var count = 0;
- List<string> names = new List<string>();
- while (number > 0)
- {
- var input = Console.ReadLine().Split().ToArray();
- var grades = new double[input.Length - 1];
- names.Insert(count, input[0]);
- for (int i = 1; i < input.Length; i++)
- {
- grades[i - 1] = double.Parse(input[i]);
- }
- Student student = new Student(input[0], grades);
- studentByAverageGrade[names[count]] = grades.Average();
- number--;
- count++;
- }
- foreach (var student in studentByAverageGrade.OrderBy(x => x.Key).ThenBy(x => x.Value))
- {
- if (student.Value > 5.00)
- {
- Console.WriteLine($"{student.Key} -> {student.Value:F2}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement