NedyalkoKikov

CountNumbersV2

Jun 2nd, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 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 CountNumbersV2
  8. {
  9. class CountNumbersV2
  10. {
  11. static void Main()
  12. {
  13. List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
  14. numbers.Sort();
  15. int[] counterNums = new int[numbers.Max() + 1];
  16. foreach(int n in numbers)
  17. {
  18. counterNums[n]++;
  19. }
  20. for (int i = 0; i < counterNums.Length; i++)
  21. {
  22. if(counterNums[i] > 0)
  23. {
  24. Console.WriteLine("{0} -> {1}",i,counterNums[i]);
  25. }
  26. }
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment