Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.CSharp;
- namespace Order_By_Age
- {
- class Program
- {
- static void Main(string[] args)
- {
- int times = int.Parse(Console.ReadLine());
- Dictionary<string, string> list = new Dictionary<string, string>();
- for (int i = 0; i < times; i++)
- {
- string[] command = Console.ReadLine().Split().ToArray();
- if (command[0] == "register")
- {
- if (list.ContainsKey(command[1]))
- {
- Console.WriteLine($"ERROR: already registered with plate number {command[2]}");
- }
- else
- {
- list.Add(command[1], command[2]);
- Console.WriteLine($"{command[1]} registered {command[2]} successfully");
- }
- }
- if (command[0] == "unregister")
- {
- if (list.ContainsKey(command[1]))
- {
- list.Remove(command[1]);
- Console.WriteLine($"{command[1]} unregistered successfully");
- }
- else
- {
- Console.WriteLine($"ERROR: user {command[1]} not found");
- }
- }
- }
- foreach (var item in list)
- {
- Console.WriteLine($"{item.Key} => {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement