Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CountRealNumbers
- {
- class MainClass
- {
- public static void Main()
- {
- List<int> listOfNumbers = Console.ReadLine().Split().Select(int.Parse).ToList();
- SortedDictionary<int, int> sortedDict = new SortedDictionary<int, int>();
- for (int i = 0; i <= listOfNumbers.Count - 1; i++)
- {
- if (sortedDict.ContainsKey(listOfNumbers[i]) == false)
- {
- sortedDict[listOfNumbers[i]] = 1;
- }
- else
- {
- sortedDict[listOfNumbers[i]]++;
- }
- }
- foreach (var item in sortedDict)
- {
- Console.WriteLine($"{item.Key} -> {item.Value}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment