Advertisement
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[] command = Console.ReadLine().Split(" -> ");
- Dictionary<string, List<string>> dictOfEmployees = new Dictionary<string, List<string>>();
- while (command[0] != "End")
- {
- string companyName = command[0];
- string id = command[1];
- if (!dictOfEmployees.ContainsKey(companyName))
- {
- dictOfEmployees.Add(companyName, new List<string>() { id });
- }
- else if (dictOfEmployees.ContainsKey(companyName) && !dictOfEmployees[companyName].Contains(id))
- {
- dictOfEmployees[companyName].Add(id);
- }
- command = Console.ReadLine().Split(" -> ");
- }
- foreach (var item in dictOfEmployees.OrderBy(x => x.Key))
- {
- Console.WriteLine(item.Key);
- foreach (var id in dictOfEmployees[item.Key])
- {
- Console.WriteLine($"-- {id}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement