Advertisement
NadyaMisheva

Untitled

Mar 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 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 == "Add visitor on position")
  22. {
  23. string newName = Console.ReadLine();
  24. int place = int.Parse(Console.ReadLine());
  25. names.insert(place, newName);
  26. }*/
  27. else if(command == "Add visitor on position")
  28. {
  29. string newName = Console.ReadLine();
  30. int index1 = int.Parse(Console.ReadLine());
  31. names.insert(index1, newName);
  32. }
  33. else if(command == "Remove last visitor")
  34. {
  35. names.RemoveAt(names.Count - 1);
  36. }
  37. else if(command == "Remove first visitor")
  38. {
  39. names.RemoveAt(0);
  40. }
  41.  
  42. }
  43. Console.WriteLine(string.Join(", ", names));
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement