Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _03.HouseParty
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11.  
  12. List<string> guests = new List<string>();
  13. for (int i = 0; i < n; i++)
  14. {
  15. string[] command = Console.ReadLine().Split();
  16.  
  17. if (command.Length == 3)
  18. {
  19. if (guests.Contains(command[0]))
  20. {
  21. Console.WriteLine($"{command[0]} is already in the list!");
  22. }
  23. else
  24. {
  25. guests.Add(command[0]);
  26.  
  27. }
  28.  
  29. }
  30. else
  31. {
  32. if (guests.Contains(command[0]))
  33. {
  34. guests.Remove(command[0]);
  35. }
  36. else
  37. {
  38. Console.WriteLine($"{command[0]} is not in the list!");
  39.  
  40. }
  41. }
  42. }
  43. Console.WriteLine(string.Join(" ", guests));
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement