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.RegularExpressions;
- using System.Runtime.InteropServices;
- using System.Data;
- using System.IO;
- using System.Reflection.PortableExecutable;
- namespace _02._Boss_Rush
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] command = Console.ReadLine().Split();
- Dictionary<string, List<string>> magic = new Dictionary<string, List<string>>();
- while (command[0] != "End")
- {
- if (command[0] == "Enroll")
- {
- if (magic.ContainsKey(command[1]))
- {
- Console.WriteLine($"{command[1]} is already enrolled.");
- }
- else
- {
- magic[command[1]] = new List<string>();
- }
- }
- if (command[0] == "Learn")
- {
- if (magic.ContainsKey(command[1]))
- {
- bool spellExist = false;
- foreach (var item in magic)
- {
- if (item.Value.Contains(command[2]))
- {
- spellExist = true;
- }
- }
- if (spellExist)
- {
- Console.WriteLine($"{command[1]} has already learnt {command[2]}.");
- }
- else
- {
- magic[command[1]].Add(command[2]);
- }
- }
- else
- {
- Console.WriteLine($"{command[1]} doesn't exist.");
- }
- }
- if (command[0] == "Unlearn")
- {
- if (magic.ContainsKey(command[1]))
- {
- bool spellExist = false;
- foreach (var item in magic)
- {
- if (item.Value.Contains(command[2]))
- {
- spellExist = true;
- }
- }
- if (spellExist)
- {
- magic[command[1]].Remove(command[2]);
- }
- else
- {
- Console.WriteLine($"{command[1]} doesn't know {command[2]}.");
- }
- }
- else
- {
- Console.WriteLine($"{command[1]} doesn't exist.");
- }
- }
- command = Console.ReadLine().Split();
- }
- Console.WriteLine("Heroes:");
- foreach (var item in magic.OrderByDescending(x => x.Value.Count).ThenBy(x => x.Key))
- {
- Console.WriteLine($"== {item.Key}: {string.Join(", ", item.Value)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement