NedyalkoKikov

SumNumbers

May 17th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 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 SortedDictionary
  8. {
  9. class SortedNumbers
  10. {
  11. static void Main()
  12. {
  13. var nums = Console.ReadLine().Split(' ').Select(double.Parse).ToList();
  14. var count = new SortedDictionary<double, int>();
  15. foreach(var n in nums)
  16. {
  17. if (count.ContainsKey(n))
  18. {
  19. count[n]++;
  20. }
  21. else
  22. {
  23. count[n] = 1;
  24. }
  25.  
  26. }
  27. foreach(var pair in count)
  28. {
  29. Console.WriteLine("{0} - {1} times", pair.Key, pair.Value);
  30.  
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment