Advertisement
knoteva

Untitled

Oct 14th, 2019
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _04._Students
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<Student> articles = new List<Student>();
  12.             int n = int.Parse(Console.ReadLine());
  13.  
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 string[] data = Console.ReadLine().Split(" ");
  17.                 articles.Add(new Student(data));
  18.             }
  19.             articles = articles.OrderByDescending(x => x.Grade).ToList();
  20.             articles.ForEach(x => Console.WriteLine(x.ToString()));
  21.         }
  22.     }
  23.     class Student
  24.     {
  25.         public string FirstName { get; set; }
  26.         public string SecondName { get; set; }
  27.         public double Grade { get; set; }
  28.  
  29.         public Student(string[] data)
  30.         {
  31.             FirstName = data[0];
  32.             SecondName = data[1];
  33.             Grade = double.Parse(data[2]);
  34.         }
  35.  
  36.         public override string ToString()
  37.         {
  38.             return $"{FirstName} {SecondName}: {Grade:F2}";
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement