Advertisement
Nikolay-qwer

izpit

Mar 24th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp59
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.  
  15.  
  16.             List<string> names = Console.ReadLine().Split(',').ToList();
  17.             while (true)
  18.             {
  19.                 string cmd = Console.ReadLine();
  20.                 if (cmd== "END")
  21.                 {
  22.                     break;
  23.                 }
  24.                 else if (cmd == "Add visitor")
  25.                 {
  26.                     string newMember = Console.ReadLine();
  27.                     names.Add(newMember);
  28.                 }
  29.                 else if (cmd == "Remove last visitor")
  30.                 {
  31.                     names.RemoveAt(names.Count - 1);
  32.                 }
  33.                 else if (cmd == "Remove first visitor")
  34.                 {
  35.                     names.RemoveAt(0);
  36.                 }
  37.                 else if (cmd == "Remove visitor on position")
  38.                 {
  39.                     int position = int.Parse(Console.ReadLine());
  40.                     names.RemoveAt(position);
  41.                 }
  42.                 else if (cmd == "Add visitor on position")
  43.                 {
  44.                     string newMember = Console.ReadLine();
  45.                     int position = int.Parse(Console.ReadLine());
  46.                     names.Insert(position, newMember);
  47.                 }
  48.  
  49.                 }
  50.             Console.WriteLine(string.Join(", ", names));
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement