Advertisement
NadyaMisheva

Untitled

Mar 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. public class Program
  5. {
  6. public static void Main()
  7. {
  8. List<string> names = Console.ReadLine().Split(',').ToList();
  9. while(true)
  10. {
  11. string command = Console.ReadLine();
  12. if(command == "END")
  13. {
  14. break;
  15. }
  16. else if(command == "Add visitor")
  17. {
  18. string newName = Console.ReadLine();
  19. names.Add(newName);
  20. }
  21. else if(command == "Remove last visitor")
  22. {
  23. names.RemoveAt(names.Count - 1);
  24. }
  25. else if(command == "Remove first visitor")
  26. {
  27. names.RemoveAt(0);
  28. }
  29.  
  30. }
  31. Console.WriteLine(string.Join(", ", names));
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement