Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _02.EasterGifts
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> gifts = Console.ReadLine().Split().ToList();
- string[] command = Console.ReadLine().Split();
- string word = command[0];
- while (word != "No")
- {
- if (word == "OutOfStock")
- {
- string giftName = command[1];
- for (int i = 0; i < gifts.Count; i++)
- {
- if (gifts[i] == giftName)
- {
- gifts[i] = "None";
- }
- }
- }
- else if (word == "Required")
- {
- string giftName = command[1];
- int index = int.Parse(command[2]);
- if (index >= 0 && index < gifts.Count)
- {
- gifts[index] = giftName;
- }
- }
- else if (word == "JustInCase")
- {
- string giftName = command[1];
- gifts[gifts.Count - 1] = giftName;
- }
- command = Console.ReadLine().Split();
- word = command[0];
- }
- List<string> finalGifts = new List<string>();
- for (int i = 0; i < gifts.Count; i++)
- {
- if (gifts[i] != "None")
- {
- finalGifts.Add(gifts[i]);
- }
- }
- Console.WriteLine(string.Join(" ", finalGifts));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement