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