Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _03._Word_Game
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string row = Console.ReadLine();
- string [] arrayNames = row.Split(", ");
- List<string> names = new List<string>();
- foreach (string name in arrayNames)
- {
- names.Add(name);
- }
- 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