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