Advertisement
Guest User

Xdb

a guest
Mar 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Test_2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<string> names = Console.ReadLine().Split(',').ToList();
  14. string comand = Console.ReadLine();
  15.  
  16. while(comand != "END")
  17. {
  18.  
  19. switch (comand)
  20. {
  21. case "Add visitor":
  22. string visitor = Console.ReadLine();
  23. names.Add(visitor);
  24. break;
  25. case "Add visitor on position":
  26. string newV = Console.ReadLine();
  27. int index = int.Parse(Console.ReadLine());
  28. names.Insert(index, newV);
  29. break;
  30. case "Remove visitor on position":
  31. index = int.Parse(Console.ReadLine());
  32. names.Remove(names[index]);
  33. break;
  34. case "Remove last visitor":
  35. names.Remove(names[names.Count - 1]);
  36. break;
  37. case "Remove first visitor":
  38. names.Remove(names.First());
  39. break;
  40. }
  41.  
  42. comand = Console.ReadLine();
  43.  
  44. }
  45.  
  46. Console.WriteLine(string.Join(", ", names));
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement