Advertisement
social1986

Untitled

Oct 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _4.Average_Grades
  6. {
  7. public class Program
  8. {
  9. public static void Main()
  10. {
  11. var countOfStudents = int.Parse(Console.ReadLine());
  12. var studentsAndGrades = new List<Student>();
  13.  
  14. for (int i = 0; i < countOfStudents; i++)
  15. {
  16. var studentAndHisGrades = Console.ReadLine().Split(' ').ToList();
  17. var student = new Student();
  18. student.Name = studentAndHisGrades[0];
  19. studentAndHisGrades.Remove(student.Name);
  20. var grades = studentAndHisGrades.Select(double.Parse).ToArray();
  21. student.AvarageGrade = grades.Average();
  22.  
  23. if (student.AvarageGrade >= 5.50)
  24. {
  25. studentsAndGrades.Add(student);
  26. }
  27. }
  28.  
  29. foreach (var student in studentsAndGrades.OrderBy(student => student.Name).ThenByDescending(student => student.AvarageGrade))
  30. {
  31. Console.WriteLine($"{student.Name} -> {student.AvarageGrade:f2}");
  32. }
  33. }
  34. }
  35.  
  36. public class Student
  37. {
  38. public string Name { get; set; }
  39. public double AvarageGrade { get; set; }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement