Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace AlgorithmsOverStructureData
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine(); //2 3 4 5 6 7 1
- List<int> numbers = input.Split(", ").Select(int.Parse).ToList();
- Dictionary<int, int> countNumbers = new Dictionary<int, int>();
- foreach(int number in numbers)
- {
- if (countNumbers.ContainsKey(number))
- {
- countNumbers[number] += 1;
- }
- else
- {
- countNumbers.Add(number, 1);
- }
- }
- foreach(var pair in countNumbers)
- {
- Console.WriteLine(pair.Key + " - " + pair.Value + " times");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement