Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. class Student
  5. {
  6.     public string name;
  7.     public List<double> grades = new List<double>();
  8.     public double average;
  9. }
  10.  
  11. class Program
  12. {
  13.     static void Main()
  14.     {
  15.         int studentsCount = int.Parse(Console.ReadLine());
  16.  
  17.         List<Student> excellentStudents = new List<Student>();
  18.  
  19.  
  20.         for (int i = 0; i < studentsCount; i++)
  21.         {
  22.             string[] studentData = Console.ReadLine().Split().ToArray();
  23.  
  24.             Student next = new Student();
  25.  
  26.             next.name = studentData[0];
  27.  
  28.             for (int j = 1; j < studentData.Length; j++)
  29.             {
  30.                 next.grades.Add(Convert.ToDouble(studentData[j]));
  31.             }
  32.  
  33.             next.average = next.grades.Average();
  34.  
  35.             if (next.average >= 5.00)
  36.             {
  37.                 excellentStudents.Add(next);
  38.             }
  39.         }
  40.         excellentStudents = excellentStudents.OrderBy(x => x.name).ThenByDescending(x => x.average).ToList();
  41.  
  42.         foreach (var baba in excellentStudents)
  43.         {
  44.             Console.WriteLine("{0} -> {1:f2}", baba.name, baba.average);
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement