Advertisement
MZlatev

Untitled

Oct 25th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _3._HouseParty
  6. {
  7. class HouseParty
  8. {
  9.  
  10. static void Main()
  11. {
  12. int n = int.Parse(Console.ReadLine());
  13.  
  14. List<string> guests = new List<string>();
  15.  
  16. for (int i = 0; i < n; i++)
  17. {
  18. string input = Console.ReadLine();
  19.  
  20. string[] splitedInput = input.Split(" ");
  21. string name = splitedInput[0];
  22.  
  23. //if (splitedInput.Length == 3)
  24. if (splitedInput[1] == "is" && splitedInput[2] == "going!")
  25. {
  26. if (!guests.Contains(name))
  27. {
  28. guests.Add(name);
  29. }
  30.  
  31. else
  32. {
  33. Console.WriteLine($"{name} is already in the list!");
  34. }
  35.  
  36. }
  37.  
  38. //if (splitedInput.Length == 4)
  39. if (splitedInput[2] == "not")
  40. {
  41. if (guests.Contains(name))
  42. {
  43. guests.Remove(name);
  44. }
  45.  
  46. else
  47. {
  48. Console.WriteLine($"{name} is not in the list!");
  49. }
  50. }
  51.  
  52.  
  53. }
  54. Console.WriteLine(string.Join(Environment.NewLine, guests));
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement