Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Easter_gift
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> gifts = Console.ReadLine().Split().ToList();
- string command = string.Empty;
- while((command=(Console.ReadLine()))!="No Money")
- {
- string[] parts = command.Split();
- string action=parts[0];
- string product=parts[1];
- if(action=="OutOfStock")
- {
- string gift="None";
- if(gifts.Contains(product))
- {
- for (int i= 0; i < gifts.Count; i++)
- {
- if(gifts[i]==product)
- {
- gifts[i]=gift;
- }
- }
- }
- }
- else if(action=="Required")
- {
- int index=int.Parse(parts[2]);
- if(index>=0 && index<gifts.Count)
- {
- gifts[index] = product;
- }
- }
- else if(action=="JustInCase")
- {
- gifts[gifts.Count - 1] = product;
- }
- }
- for (int i = 0; i < gifts.Count; i++)
- {
- if(gifts[i]!="None")
- {
- Console.Write(gifts[i]+" ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement