Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace P08.Company_Users
- {
- class Program
- {
- static void Main(string[] args)
- {
- var companyInfo = new Dictionary<string, List<string>>();
- string cmd;
- while ((cmd = Console.ReadLine()) != "End")
- {
- string[] command = cmd.Split(" -> ").ToArray();
- string companyName = command[0];
- string ID = command[1];
- if (!companyInfo.ContainsKey(companyName))
- {
- var IDnumber = new List<string>
- {
- ID
- };
- companyInfo.Add(companyName, IDnumber);
- }
- if (!companyInfo[companyName].Contains(ID))
- {
- companyInfo[companyName].Add(ID);
- }
- }
- foreach (var item in companyInfo.OrderBy(x => x.Key))
- {
- Console.WriteLine($"{item.Key}");
- foreach (var number in item.Value)
- {
- Console.WriteLine($"-- {number}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement