Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Theatre_Patients
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- List<string> names = Console.ReadLine().Split(", ").ToList();
- string command = Console.ReadLine();
- while (command != "END")
- {
- if (command == "Add visitor")
- {
- string newName = Console.ReadLine();
- names.Add(newName);
- }
- else if (command == "Add visitor on position")
- {
- string name = Console.ReadLine();
- int index = int.Parse(Console.ReadLine());
- names.Insert(index, name);
- }
- else if (command == "Remove visitor on position")
- {
- int index = int.Parse(Console.ReadLine());
- names.RemoveAt(index);
- }
- else if (command == "Remove last visitor")
- {
- names.RemoveAt(names.Count - 1);
- }
- else if (command == "Remove first visitor")
- {
- names.RemoveAt(0);
- }
- command = Console.ReadLine();
- }
- Console.WriteLine(string.Join(" ", names));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement