Advertisement
Guest User

Untitled

a guest
Jul 6th, 2021
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Numbers
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
  12.  
  13. List<int> finalNumbers = new List<int>();
  14.  
  15.  
  16. double averageNum = numbers.Sum() / (double)numbers.Count;
  17.  
  18. int counter = 0;
  19.  
  20.  
  21. for (int i = 0; i < numbers.Count; i++)
  22. {
  23.  
  24. if (numbers[i] > averageNum)
  25. {
  26. finalNumbers.Add(numbers[i]);
  27. counter++;
  28. }
  29. }
  30.  
  31. if (counter == 0)
  32. {
  33. Console.WriteLine("No");
  34. return;
  35. }
  36.  
  37.  
  38. for (int i = 0; i < finalNumbers.Count -1; i++)
  39. {
  40. if (finalNumbers[i] < finalNumbers[i + 1] && finalNumbers.Count > 5)
  41. {
  42. finalNumbers.Remove(finalNumbers[i]);
  43. i = -1;
  44.  
  45. }
  46. }
  47.  
  48. finalNumbers = finalNumbers.OrderByDescending(x => x).ToList();
  49.  
  50. Console.WriteLine(String.Join(" ", finalNumbers));
  51. }
  52. }
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement