Advertisement
desislava_topuzakova

02.

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