Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Linq;
  5.  
  6. namespace Company_Users
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             var input = new Dictionary<string, List<string>>();
  13.             string inputLine = Console.ReadLine();
  14.             while (inputLine != "End")
  15.             {
  16.                 List<string> command = inputLine.Split(" -> ").ToList();
  17.                 string companyName = command[0];
  18.                 string IDOfEmployee = command[1];
  19.  
  20.                 if (!input.ContainsKey(companyName))
  21.                 {
  22.                     input.Add(companyName, new List<string>());
  23.                 }
  24.                 if (!input[companyName].Contains(IDOfEmployee))
  25.                 {
  26.                     input[companyName].Add(IDOfEmployee);
  27.                 }
  28.                 inputLine = Console.ReadLine();
  29.             }
  30.  
  31.             foreach (var kvp in input.OrderBy(kvp => kvp.Key))
  32.             {
  33.                 Console.WriteLine($"{kvp.Key}");
  34.                 foreach (var IdOfEmployee in kvp.Value)
  35.                 {
  36.                     Console.WriteLine($"-- {IdOfEmployee}");
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement