Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.IO;
- namespace CompanyUsers
- {
- class Program
- {
- public static void Main()
- {
- var usersByCompany = new Dictionary<string, List<string>>();
- //var idsBy = new Dictionary<string,>();
- while (true)
- {
- string[] tokens = Console.ReadLine().Split("-> ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
- if (tokens[0] == "End")
- {
- break;
- }
- string companyName = tokens[0];
- string employeeId = tokens[1];
- if (usersByCompany.ContainsKey(companyName) == false)
- {
- usersByCompany.Add(companyName, new List<string>());
- }
- if (usersByCompany[companyName].Contains(employeeId) == false) // pf... it was that simple...
- {
- usersByCompany[companyName].Add(employeeId);
- }
- }
- foreach (var kvp in usersByCompany.OrderBy(c => c.Key))
- {
- Console.WriteLine(kvp.Key);
- kvp.Value.ForEach(x => Console.WriteLine("-- {0}", x));
- }
- }
- }
- } // . yooooooooooooooooooooooooooo
Advertisement
Add Comment
Please, Sign In to add comment