Advertisement
Lamms

CategorizeMinMax

Sep 20th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CategorizeMinMax
  8. {
  9. class _03CategorizeMinMax
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14.  
  15. double[] arr = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
  16. List<double> doubleSet = new List<double>();
  17. List<double> intSet = new List<double>();
  18. for (int i = 0; i < arr.Length; i++)
  19. {
  20. if (arr[i]%1 !=0)
  21. {
  22. doubleSet.Add(arr[i]);
  23. }
  24. if (arr[i] % 1 == 0)
  25. {
  26. intSet.Add(arr[i]);
  27. }
  28. }
  29.  
  30. Console.WriteLine("Double");
  31. Console.Write(string.Join(" ", doubleSet));
  32. Console.WriteLine();
  33. Console.Write("min {0}; max {1}, sum {2}, average {3:f2}", doubleSet.Min(), doubleSet.Max(),doubleSet.Sum(), doubleSet.Average());
  34.  
  35. Console.WriteLine();
  36.  
  37. Console.WriteLine("Int");
  38. Console.Write(string.Join(" ", intSet));
  39. Console.WriteLine();
  40. Console.Write("min {0}; max {1}, sum {2}, average {3:f2}", intSet.Min(), intSet.Max(), intSet.Sum(), intSet.Average());
  41.  
  42.  
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement