Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace fundamental14
- {
- class MainClass
- {
- public static void Main()
- {
- Dictionary<string, List<string>> store = new Dictionary<string, List<string>>();
- string input = string.Empty;
- while((input = Console.ReadLine()) != "END")
- {
- string[] arry = input.Split("->").ToArray();
- string command = arry[0];
- string storeList = arry[1];
- if (command == "Add")
- {
- List<string> items = arry[2].Split(",").ToList();
- if(!store.ContainsKey(storeList))
- {
- store.Add(storeList, items);
- }
- else
- {
- foreach (var item in items)
- {
- store[storeList].Add(item);
- }
- }
- }
- else
- {
- if(store.ContainsKey(storeList))
- {
- store.Remove(storeList);
- }
- }
- }
- Console.WriteLine("Stores list:");
- foreach (var kvp in store.OrderByDescending(x => x.Value.Count).ThenByDescending(x => x.Key))
- {
- Console.WriteLine($"{kvp.Key}");
- foreach (var product in kvp.Value)
- {
- Console.WriteLine($"<<{product}>>");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement