Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Easter_Gifts
- {
- class Program
- {
- static void Main()
- {
- string[] gifts = Console.ReadLine()
- .Split()
- .ToArray();
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "No Money")
- {
- break;
- }
- else
- {
- string[] checkGifts = command
- .Split()
- .ToArray();
- string gift = checkGifts[1];
- if (checkGifts[0] == "OutOfStock")
- {
- gifts = gifts.Select(x => x == gift ? "None" : x).ToArray();
- }
- else if (checkGifts[0] == "Required")
- {
- int index = int.Parse(checkGifts[2]);
- if (index >= 0 && index < gifts.Length)
- {
- gifts[index] = gift;
- }
- }
- else if (checkGifts[0] == "JustInCase")
- {
- gifts[gifts.Length - 1] = gift;
- }
- }
- }
- foreach (var s in gifts.Where(s => s != "None"))
- {
- Console.Write($"{s} ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement