Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- Predicate<string> match;
- List<string> name = Console.ReadLine()
- .Split(" ",StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- string command;
- while((command=Console.ReadLine())!="Party")
- {
- string[] commands=command
- .Split(" ",StringSplitOptions.RemoveEmptyEntries);
- switch(commands[1].ToLower())
- {
- case "startswith":
- match=x=>x.StartsWith(commands[2]);
- break;
- case "Endswith":
- match=x=>x.EndsWith(commands[2]);
- break;
- case "length":
- match=x=>int.Parse(commands[2])==x.Length;
- break;
- default:
- match=null;
- break;
- }
- for(int i=0;i<name.Count;i++)
- {
- if(commands[0].ToLower()=="remove")
- {
- if(match(commands[2]))
- {
- name.RemoveAt(i);
- i--;
- }
- }
- else
- {
- if(match(commands[2]))
- {
- name.Insert(i,commands[2]);
- i++;
- }
- }
- }
- }
- Console.WriteLine(string.Join(" ",name));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement