Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Numerics;
- using System.Text;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Reflection.Metadata.Ecma335;
- using System.Runtime.ExceptionServices;
- using System.Threading;
- using System.Text.RegularExpressions;
- namespace ConsoleApp24
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> biscuits = Console.ReadLine().Split(", ").ToList();
- string input = Console.ReadLine();
- while (input != "Eat")
- {
- string[] commands = input.Split();
- switch (commands[0])
- {
- case "Update-Any":
- for (int i = 0; i < biscuits.Count-1; i++)
- {
- if (biscuits[i] == commands[1])
- {
- string outOfStock = "Out of stock";
- biscuits[i] = outOfStock;
- }
- }
- break;
- case "Replace":
- int indexExtra = int.Parse(commands[2]);
- string value = commands[1];
- if (indexExtra >= 0 && indexExtra < biscuits.Count)
- {
- biscuits[indexExtra] = value;
- }
- break;
- case "Update-Last":
- string last = biscuits[biscuits.Count - 1];
- biscuits.Remove(last);
- biscuits.Add(commands[1]);
- break;
- case "Rearrange":
- if (biscuits.Contains(commands[1]))
- {
- biscuits.Remove(commands[1]);
- biscuits.Add(commands[1]);
- }
- break;
- }
- input = Console.ReadLine();
- }
- for (int i = 0; i < biscuits.Count; i++)
- {
- if (biscuits[i] == "Out of stock")
- {
- biscuits.Remove("Out of stock");
- }
- }
- Console.WriteLine(string.Join(" ", biscuits));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment