Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- string[] namesOfGifts = Console.ReadLine().Split(" ");
- string input = string.Empty;
- while ((input = Console.ReadLine()) != "No Money")
- {
- string[] tokens = input.Split(" ");
- string command = tokens[0];
- if (command == "OutOfStock")
- {
- string gift = tokens[1];
- int index = Array.IndexOf(namesOfGifts, gift);
- while (index != -1)
- {
- namesOfGifts[index] = "None";
- index = Array.IndexOf(namesOfGifts, gift);
- }
- }
- else if (command == "Required")
- {
- string gift = tokens[1];
- int index = int.Parse(tokens[2]);
- if (index >= 0 && index < namesOfGifts.Length)
- {
- namesOfGifts[index] = gift;
- }
- }
- else if (command == "JustInCase")
- {
- string gift = tokens[1];
- namesOfGifts[namesOfGifts.Length - 1] = gift;
- }
- }
- namesOfGifts = namesOfGifts.Where(x => x != "None").ToArray();
- Console.WriteLine(string.Join(" ", namesOfGifts));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement