Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CompanyUsers
- {
- class Program
- {
- static void Main(string[] args)
- {
- var companiesAndEmployeesDictionary = new SortedDictionary<string, List<string>>();
- string command = string.Empty;
- while ((command = Console.ReadLine()) != "End")
- {
- string [] commandArray = command.Split(" -> ");
- string company = commandArray[0];
- string id = commandArray[1];
- if (companiesAndEmployeesDictionary.ContainsKey(company) == false)
- {
- companiesAndEmployeesDictionary[company] = new List<string>();
- companiesAndEmployeesDictionary[company].Add(id);
- }
- else
- {
- if (companiesAndEmployeesDictionary[company].Contains(id) == false)
- {
- companiesAndEmployeesDictionary[company].Add(id);
- }
- }
- }
- foreach (var kvp in companiesAndEmployeesDictionary)
- {
- string company = kvp.Key;
- List<string>listIds = kvp.Value;
- Console.WriteLine($"{company}");
- foreach (var id in listIds)
- {
- Console.WriteLine($"-- {id}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement