Advertisement
Guest User

Untitled

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