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 _4.Average_Grades
- {
- public class Student
- {
- public string name { get; set; }
- public List<double> grades { get; set;}
- public double averageGrade { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- var listStudents = new List<Student>();
- for (int i = 0; i < n; i++)
- {
- listStudents.Add(new Student());
- }
- for (int i = 0; i < n; i++)
- {
- var input = Console.ReadLine().Split().ToArray();
- listStudents[i].name = input[0];
- listStudents[i].grades = new List<double>();
- for (int f = 1; f < input.Length; f++)
- {
- listStudents[i].grades.Add(double.Parse(input[f]));
- }
- listStudents[i].averageGrade = listStudents[i].grades.Average();
- }
- List<Student> exellentGrades = new List<Student>();
- foreach (var item in listStudents)
- {
- if (item.averageGrade>=5)
- {
- exellentGrades.Add(item);
- }
- }
- foreach (var item in exellentGrades.OrderBy(x=>x.name).ThenBy(x=>-x.averageGrade))
- {
- Console.WriteLine("{0} -> {1:f2}",item.name,item.averageGrade);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment