Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace CompanyUsers
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input;
- Dictionary<string, List<string>> companies = new Dictionary<string, List<string>>();
- while((input = Console.ReadLine()) != "End")
- {
- string[] separated = input.Split(" -> ");
- string compName = separated[0];
- string id = separated[1];
- if (companies.ContainsKey(compName))
- {
- companies[compName].Add(id);
- }
- else
- {
- companies.Add(compName, new List<string>());
- companies[compName].Add(id);
- }
- }
- var ordered = companies.OrderBy(k => k.Key);
- foreach(var item in ordered)
- {
- Console.WriteLine(item.Key);
- foreach(var list in item.Value)
- {
- Console.WriteLine("--" + list);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment