desislava_topuzakova

2.

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