Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Data;
- using System.Security.Cryptography.X509Certificates;
- List<string> coffees = Console.ReadLine()
- .Split()
- .ToList();
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string[] command = Console.ReadLine()
- .Split();
- if (command[0] == "Include")
- {
- string coffee = command[1];
- coffees.Add(coffee);
- }
- else if (command[0] == "Remove")
- {
- string commandInfo = command[1];
- int numbersCoffeeToRemove = int.Parse(command[2]);
- if (numbersCoffeeToRemove <= coffees.Count)
- {
- if (commandInfo == "first")
- {
- coffees.RemoveRange(0, numbersCoffeeToRemove);
- }
- else
- {
- coffees.RemoveRange(coffees.Count - numbersCoffeeToRemove, numbersCoffeeToRemove);
- }
- }
- }
- else if (command[0] == "Prefer")
- {
- int index1 = int.Parse(command[1]);
- int index2 = int.Parse(command[2]);
- if (index1 >= 0 && index1 <= coffees.Count && index2 >= 0 && index2 <= coffees.Count)
- {
- string corectElement = coffees[index1];
- coffees[index1] = coffees[index2];
- coffees[index2] = corectElement;
- }
- }
- else if (command[0] == "Reverse")
- {
- coffees.Reverse();
- }
- }
- Console.WriteLine("Coffees:");
- Console.WriteLine(string.Join(" ", coffees));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement