VPanev

Untitled

Nov 11th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace ConsoleApp1
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<int> numbers = Console.ReadLine().Split(',').Select(int.Parse).ToList();
  12. List<int> belowAvg = new List<int>();
  13. List<int> aboveAvg = new List<int>();
  14. numbers.Average();
  15.  
  16. foreach (int number in numbers)
  17. {
  18.  
  19. if (number < numbers.Average())
  20. {
  21. belowAvg.Add(number);
  22. }
  23.  
  24. else
  25. {
  26. aboveAvg.Add(number);
  27. }
  28. }
  29.  
  30. Console.WriteLine($"avg: {numbers.Average():f2}");
  31. Console.WriteLine($"below: {string.Join(",", belowAvg)}");
  32. Console.WriteLine($"above: {string.Join(",", aboveAvg)}");
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment