Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DZNEW
- {
- class Program
- {
- static void Main()
- {
- List<String> list = new List<String>();
- String str = "111 111 222 222 222 333 333 333 333 333";
- String[] arr = str.Split(' ');
- Dictionary<String, int> collection = new Dictionary<String, int>();
- foreach (String element in arr)
- {
- list.Add(element);
- }
- int count = 0;
- for(int i = 0; i < list.Count; i++)
- {
- count = 0;
- for(int j = 0; j < list.Count; j++)
- {
- if(list[i] == list[j])
- {
- count++;
- }
- }
- if (!collection.ContainsKey(list[i]))
- {
- collection.Add(list[i], count);
- }
- }
- foreach(var element in collection)
- {
- Console.WriteLine("{0} - {1}", element.Key, element.Value);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement