Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> finalNumbers = new List<int>();
- double averageNum = numbers.Sum() / (double)numbers.Count;
- int counter = 0;
- for (int i = 0; i < numbers.Count; i++)
- {
- if (numbers[i] > averageNum)
- {
- finalNumbers.Add(numbers[i]);
- counter++;
- }
- }
- if (counter == 0)
- {
- Console.WriteLine("No");
- return;
- }
- for (int i = 0; i < finalNumbers.Count -1; i++)
- {
- if (finalNumbers[i] < finalNumbers[i + 1] && finalNumbers.Count > 5)
- {
- finalNumbers.Remove(finalNumbers[i]);
- i = -1;
- }
- }
- finalNumbers = finalNumbers.OrderByDescending(x => x).ToList();
- Console.WriteLine(String.Join(" ", finalNumbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement