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 ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- string names = Console.ReadLine();
- List<string> Lnames = names.Split(' ').ToList();
- string s;
- do
- {
- s = Console.ReadLine();
- if (s == "Add visitor")
- {
- string c1 = Lnames[Lnames.Count - 1] + ",";
- Lnames.RemoveAt(Lnames.Count - 1);
- Lnames.Add(c1);
- string name = Console.ReadLine();
- Lnames.Add((name));
- }
- else if(s=="Add visitor on position")
- {
- string n = (Console.ReadLine()+",");
- int z = int.Parse(Console.ReadLine());
- Lnames.Insert(z,n);
- }
- else if(s =="Remove visitor on position")
- {
- int n = int.Parse(Console.ReadLine());
- Lnames.RemoveAt(n);
- }
- else if(s=="Remove last visitor")
- {
- Lnames.RemoveAt(Lnames.Count-1);
- }
- else if(s=="Remove first visitor")
- {
- Lnames.RemoveAt(0);
- }
- }
- while (s != "END");
- for(int i=0;i<Lnames.Count;i++)
- {
- if(i!= Lnames.Count-1)
- Console.Write(Lnames[i]+" ");
- else if(i== Lnames.Count - 1)
- Console.Write(Lnames[i] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment