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