Advertisement
VickSuna

Untitled

Jun 19th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _2._Exec_03._House_Party
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int n = int.Parse(Console.ReadLine());
  12. List<string> guests = new List<string>();
  13.  
  14. while (n > 0)
  15. {
  16. string[] command = Console.ReadLine().Split(); // Ако го прочета преди цикъла дава грешка!!!!!
  17. string name = command[0];
  18. if (command[2] == "going!")
  19. {
  20. if (guests.Contains(name))
  21. {
  22. Console.WriteLine($"{name} is already in the list!");
  23. }
  24. else
  25. {
  26. guests.Add(name);
  27. }
  28. }
  29. else
  30. {
  31. if (guests.Contains(name))
  32. {
  33. guests.Remove(name);
  34. }
  35. else
  36. {
  37. Console.WriteLine($"{name} is not in the list!");
  38. }
  39. }
  40. n--;
  41. }
  42. // Console.WriteLine(String.Join(" ", guests));
  43. for (int i = 0; i < guests.Count; i++)
  44. {
  45. Console.WriteLine(guests[i]);
  46. }
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement