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