Advertisement
Mirineo

Whatever

Feb 12th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. namespace _4.AverageGrades
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6.  
  7. public class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var number = int.Parse(Console.ReadLine());
  12. var studentByAverageGrade = new Dictionary<string, double>();
  13. var count = 0;
  14. List<string> names = new List<string>();
  15.  
  16. while (number > 0)
  17. {
  18. var input = Console.ReadLine().Split().ToArray();
  19.  
  20. var grades = new double[input.Length - 1];
  21.  
  22. names.Insert(count, input[0]);
  23.  
  24. for (int i = 1; i < input.Length; i++)
  25. {
  26. grades[i - 1] = double.Parse(input[i]);
  27. }
  28. Student student = new Student(input[0], grades);
  29.  
  30. studentByAverageGrade[names[count]] = grades.Average();
  31.  
  32. number--;
  33. count++;
  34. }
  35.  
  36. foreach (var student in studentByAverageGrade.OrderBy(x => x.Key).ThenBy(x => x.Value))
  37. {
  38. if (student.Value > 5.00)
  39. {
  40. Console.WriteLine($"{student.Key} -> {student.Value:F2}");
  41. }
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement