Advertisement
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> names = Console.ReadLine().Split(',').ToList();
- while (true)
- {
- string cmd = Console.ReadLine();
- if (cmd== "END")
- {
- break;
- }
- else if (cmd == "Add visitor")
- {
- string newMember = Console.ReadLine();
- names.Add(newMember);
- }
- else if (cmd == "Remove last visitor")
- {
- names.RemoveAt(names.Count - 1);
- }
- else if (cmd == "Remove first visitor")
- {
- names.RemoveAt(0);
- }
- else if (cmd == "Remove visitor on position")
- {
- int position = int.Parse(Console.ReadLine());
- names.RemoveAt(position);
- }
- else if (cmd == "Add visitor on position")
- {
- string newMember = Console.ReadLine();
- int position = int.Parse(Console.ReadLine());
- names.Insert(position, newMember);
- }
- }
- Console.WriteLine(string.Join(", ", names));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement