Advertisement
DeeAG

03.Numbers

Feb 24th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _03.Numbers2
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> sequence = Console.ReadLine()
  12.                 .Split(' ', StringSplitOptions.RemoveEmptyEntries)
  13.                 .Select(int.Parse)
  14.                 .ToList();
  15.  
  16.             List<int> resultSequence = sequence
  17.                 .Where(x => x > sequence.Average())
  18.                 .ToList();
  19.  
  20.             if (resultSequence.Count == 0)
  21.             {
  22.                 Console.WriteLine("No");
  23.                 return;
  24.             }
  25.  
  26.             Console.WriteLine(string.Join(' ', resultSequence.OrderByDescending(x => x).Take(Math.Min(5, resultSequence.Count))));
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement