Advertisement
YavorGrancharov

Array_Data(lambda)

Jul 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Array_Data
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12.  
  13.             string comm = Console.ReadLine();
  14.  
  15.             double avg = input.Average();
  16.             foreach (var x in input.Where(n => n < avg).ToList())
  17.             {
  18.                 input.Remove(x);
  19.             }
  20.             input.Sort();
  21.  
  22.             int max = input.Max();
  23.             int min = input.Min();
  24.  
  25.             switch (comm)
  26.             {
  27.                 case "Max":
  28.                     Console.WriteLine("{0}", max);
  29.                     break;
  30.                 case "Min":
  31.                     Console.WriteLine("{0}", min);
  32.                     break;
  33.                 case "All":
  34.                     Console.WriteLine("{0}", string.Join(" ", input));
  35.                     break;
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement