Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5. using System.Text;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int number = int.Parse(Console.ReadLine());
  14.  
  15.  
  16. var students = new Dictionary<string, string>();
  17.  
  18. for (int i = 0; i < number; i++)
  19. {
  20. string[] input = Console.ReadLine().Split().ToArray();
  21.  
  22. string todo = input[0];
  23.  
  24.  
  25. if (todo == "register")
  26. {
  27. string licensenumber = input[2];
  28.  
  29. if (students.ContainsValue(licensenumber))
  30. {
  31. Console.WriteLine($"ERROR: already registered with plate number {licensenumber}");
  32. }
  33. else
  34. {
  35. string student = input[1];
  36. students.Add(student, licensenumber);
  37. Console.WriteLine($"{student} registered {licensenumber} successfully");
  38. }
  39.  
  40. }
  41. else
  42. {
  43. string student = input[1];
  44. if (!students.ContainsKey(student))
  45. {
  46. Console.WriteLine($"ERROR: user {student} not found");
  47. }
  48. else
  49. {
  50. students.Remove(student);
  51. Console.WriteLine($"{student} unregistered successfully");
  52. }
  53. }
  54. }
  55. foreach (var item in students)
  56. {
  57. Console.WriteLine($"{item.Key} => {item.Value}");
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement