NedyalkoKikov

CountNumber

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